MCPcopy Create free account
hub / github.com/Monogatari/Monogatari / state

Method state

src/monogatari.ts:819–842  ·  view source on GitHub ↗
(object?: K | Partial<StateMap>)

Source from the content-addressed store, hash-verified

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

Callers 15

labelMethod · 0.95
setupMethod · 0.95
initMethod · 0.95
setupMethod · 0.80
resetMethod · 0.80
onLoadMethod · 0.80
didApplyMethod · 0.80
didRevertMethod · 0.80
setupMethod · 0.80
onLoadMethod · 0.80
resetMethod · 0.80
applyMethod · 0.80

Calls 1

triggerMethod · 0.95

Tested by

no test coverage detected