(handler)
| 9015 | } |
| 9016 | } |
| 9017 | onStateChange(handler) { |
| 9018 | this.onStateChangeHandlers.push(handler); |
| 9019 | return () => { |
| 9020 | const index = this.onStateChangeHandlers.indexOf(handler); |
| 9021 | if (index !== -1) { |
| 9022 | this.onStateChangeHandlers.splice(index, 1); |
| 9023 | } |
| 9024 | }; |
| 9025 | } |
| 9026 | _notifyStateChange(oldState, newState) { |
| 9027 | this.onStateChangeHandlers.forEach((handler) => handler(oldState, newState)); |
| 9028 | } |