(message)
| 158 | } |
| 159 | |
| 160 | function handleMessages(message) { |
| 161 | const { |
| 162 | id, instanceId, type, action, state, toAll, |
| 163 | } = message |
| 164 | if (toAll) { |
| 165 | Object.keys(instances).forEach((key) => { |
| 166 | handleMessages({ ...message, id: key, toAll: false }) |
| 167 | }) |
| 168 | return false |
| 169 | } |
| 170 | |
| 171 | const instance = instances[id || instanceId] |
| 172 | if (!instance) return true |
| 173 | const { store, filters } = instance |
| 174 | if (!store) return false |
| 175 | |
| 176 | switch (type) { |
| 177 | case 'DISPATCH': |
| 178 | store.liftedStore.dispatch(action) |
| 179 | break |
| 180 | case 'ACTION': |
| 181 | dispatchRemotely(action, instance) |
| 182 | break |
| 183 | case 'IMPORT': |
| 184 | importPayloadFrom(store, state, instance) |
| 185 | break |
| 186 | case 'EXPORT': |
| 187 | exportState(instance) |
| 188 | break |
| 189 | case 'UPDATE': |
| 190 | relay('STATE', getLiftedState(store, filters), instance) |
| 191 | break |
| 192 | default: |
| 193 | break |
| 194 | } |
| 195 | return false |
| 196 | } |
| 197 | |
| 198 | function start(instance) { |
| 199 | if (!listenerAdded) { |
no test coverage detected