STATE MANAGER
Target - Front End Projects
Description
A tiny yet very powerful state management library. Follows pubsub architecture to maintain the state and broadcast the same. It can be used as an alternative to redux.
How do I get set up?
npm i state-manager-utility --save
Sample
; ; { ; ; ; ; { console; } }
APIs
- StoreEvent - Makes available events for listening. Adds in the list of events available for subscription
/** * Event Broadcaster method * Event can be broadcasted without storing into state or temporarily * * Expects eventName and data to be broadcasted * * @param * @param * @param * @param * @param * @param */
- DeleteEvent - Removes event detail from the store, hence any listener wont be able getting updates
/** * Removes event detail from the store, hence any listener wont be able getting updates * @param * @param */
- SubscribeToEvent - Event listener method calls back on event creation or updation
/** * @param * @param * @param * @param * @param */
- UnsubscribeEvent - Removes the event listener
/** * Unsubscribe event from listening * @param * @param * @param * @param */
- InitialiseStateManager - This method makes avilable the dependencies to the library(In this case, it expects Storage-Utility to be injected) This method can be avoided if state persistance is not required(intra session events).
/** * Initialize package with required dependencies * @param */
- IsEventAvailable - Tells if an event is already subscribed. Can be used to detect if already there is a listener for given eventName
/** * @param * @param * @param */