| 817 | */ |
| 818 | static state(object: Partial<StateMap>): StateMap; |
| 819 | static state<K extends keyof StateMap>(object?: K | Partial<StateMap>): StateMap | StateMap[K] { |
| 820 | if (typeof object === 'string') { |
| 821 | return this._state[object]; |
| 822 | } |
| 823 | |
| 824 | if (typeof object === 'object' && object !== null) { |
| 825 | const oldState = Object.assign({}, this._state); |
| 826 | const newState = merge(this._state, object); |
| 827 | |
| 828 | this.trigger('willUpdateState', { |
| 829 | oldState, |
| 830 | newState |
| 831 | }); |
| 832 | |
| 833 | this._state = newState; |
| 834 | |
| 835 | this.trigger('didUpdateState', { |
| 836 | oldState, |
| 837 | newState: this._state |
| 838 | }); |
| 839 | } |
| 840 | |
| 841 | return this._state; |
| 842 | } |
| 843 | |
| 844 | /** |
| 845 | * @static registerAction - Register an Action to the actions list. All actions |