(listener: Listener)
| 138 | }; |
| 139 | |
| 140 | const subscribe = (listener: Listener): (() => void) => { |
| 141 | listeners.push(listener); |
| 142 | return () => { // Return an unsubscribe function |
| 143 | const index = listeners.indexOf(listener); |
| 144 | if (index > -1) { |
| 145 | listeners.splice(index, 1); |
| 146 | } |
| 147 | }; |
| 148 | }; |
| 149 | |
| 150 | const getInitialState = (): PullState => { |
| 151 | return state; |