| 21203 | */ |
| 21204 | |
| 21205 | var createBroadcast = function createBroadcast(initialState) { |
| 21206 | var listeners = {}; |
| 21207 | var id = 0; |
| 21208 | var state = initialState; |
| 21209 | |
| 21210 | function publish(nextState) { |
| 21211 | state = nextState; |
| 21212 | |
| 21213 | // eslint-disable-next-line guard-for-in, no-restricted-syntax |
| 21214 | for (var key in listeners) { |
| 21215 | var listener = listeners[key]; |
| 21216 | if (listener === undefined) { |
| 21217 | // eslint-disable-next-line no-continue |
| 21218 | continue; |
| 21219 | } |
| 21220 | |
| 21221 | listener(state); |
| 21222 | } |
| 21223 | } |
| 21224 | |
| 21225 | function subscribe(listener) { |
| 21226 | var currentId = id; |
| 21227 | listeners[currentId] = listener; |
| 21228 | id += 1; |
| 21229 | listener(state); |
| 21230 | return currentId; |
| 21231 | } |
| 21232 | |
| 21233 | function unsubscribe(unsubID) { |
| 21234 | listeners[unsubID] = undefined; |
| 21235 | } |
| 21236 | |
| 21237 | return { publish: publish, subscribe: subscribe, unsubscribe: unsubscribe }; |
| 21238 | }; |
| 21239 | |
| 21240 | var _ThemeProvider$childC; |
| 21241 | var _ThemeProvider$contex; |