Skip to content
Myr

init (#560)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by M. Bagher Abiat · committed by GitHub · parent c3e974e · Browse files · 1 file+12 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+12 added−5 removed

  • other:+12 added−5 removed

1 file+12 added−5 removed

modified:src/middleware.ts+12 added-5 removed
5 unmodified lines
6 StateCreator,7 StoreApi,8} from './vanilla'910const DEVTOOLS = Symbol()1112export const redux =13 <S extends State, A extends { type: unknown }>(14 reducer: (state: S, action: A) => S,15 initial: S
92 unmodified lines
108 >(109 state: PartialState<S, K1, K2, K3, K4>,110 replace?: boolean111 ) => {112 const newState = api.getState()113 if (state !== newState) {110 savedSetState(state, replace)111 api.devtools.send(api.devtools.prefix + 'setState', api.getState())114 savedSetState(state, replace)115 api.devtools.send(api.devtools.prefix + 'setState', api.getState())116 }117 }118 options = typeof options === 'string' ? { name: options } : options119 api.devtools = extension.connect({ ...options })120 api.devtools.prefix = options?.name ? `${options.name} > ` : ''
1 unmodified line
122 if (message.type === 'DISPATCH' && message.state) {123 const ignoreState =124 message.payload.type === 'JUMP_TO_ACTION' ||125 message.payload.type === 'JUMP_TO_STATE'126 const newState = api.getState()127 ;(newState as any)[DEVTOOLS] = JSON.parse(message.state)128 if (!api.dispatch && !ignoreState) {122 api.setState(JSON.parse(message.state))129 api.setState(newState)130 } else {124 savedSetState(JSON.parse(message.state))131 savedSetState(newState)132 }133 } else if (134 message.type === 'DISPATCH' &&135 message.payload?.type === 'COMMIT'
8 unmodified lines
144 message.payload.nextLiftedState?.computedStates || []145146 computedStates.forEach(147 ({ state }: { state: PartialState<S> }, index: number) => {141 const action = actions[index] || api.devtools.prefix + 'setState'148 const action = actions[index] || 'No action found'149150 if (index === 0) {151 api.devtools.init(state)152 } else {
269 unmodified lines