Global Access
The Eagle Eye store manager is equipped with a
store property which is accessible globally.How do I access this global store?
This is done by simply utilizing the Eagle Eye store manager instance
store property.For global access to the Eagle Eye store manager's data, the store property exposes 4 methods. Namely:
getState: Provides a static snapshot of the current state. May accept a list of property paths to target properties within the state to fetch and returnresetState: Please see descriptions in thechannel.resetStatepage. May accept a parameterless invocation resulting in a noop.setState: Please see descriptions in thechannel.setStatepage.subscribeProvides the API for manual subscription to the Eagle Eye's state change and close events.Returns a parameterless void function - the unsubcriber.Accepts a "closing" event type and an observer function to be called before the Eagle Eye instance deactivation.Accepts a "data-updated" event type and an observer function for state changes.Context close event subscriptionstateManager.store.subscribe( 'closing', ( shutDownReason : string ) => void ); // => VoidFunctionData change event subscriptionstateManager.store.subscribe( 'data-updated', ( changes : Changes<State>, changedPaths : Array<Array<string>>, netChanges : Partial<State>, mayHaveChangesAt : (tokenizedPath : string[]) => boolean ) => void ); // => VoidFunctionMore on "data-updated" event listener params- changes: an object or array holding the original change request payload(s).
- changedPaths: an array of tokenized property paths belonging to state properties changed during this request.
- netChanges: an object of the final state of all properties in state changed.
- mayHaveChangesAt: a function to confirm that a given property path is among the new changes. This path is to be supplied as a tokenized string (i.e. supply
['a', 'b', 'c', '0', 'r']for'a.b.c[0].r').
State references are always snapshots of the state at the time of access. In essence, the state returned by
stateManager.store.getState(...) are not affected by subsequent updates to the store's state. Any updates to this acquired state never affects the Eagle Eye's state. So therefore, the 4 considerations:use only the
stateManager.store.setState(...) to update the Eagle Eye state manager's internal store.stateManager.store.getState(...) must be used to obtain the current state value. Please remember to join this storeManager's change stream instead if real-time change monitoring is what you need.use your
stateManager.store.subscribe(...) to manually subscribe to state changes and refresh your current state value in real-time.use the
unsubscriber returned by your Eagle Eye instance store's subscribe(...) to unsubscribe from the store when needed.