Djinn-state
A powerful yet simple application state management.
The Djinn-state was developed with the objective to be less verbose and simple to maintain and scale Javascript applications.
More information read the docs.
Features
- Supported in browsers and NodeJs
- Simple to implement
- Register and retrieve registered services by just giving the class of the service you want
- Singleton and scoped services
- Subscribe and unsubscribe to service state changes
Libraries
Install
npm npm i --save djinn-state
yarn yarn add djinn-state
Using
// djinn.js; const djinn = ; // AuthService.js state = token: '' ; { this; } // HttpService.js { super; thisauthService = djinn; } { const token = thisauthServicetoken; const headers = 'Authorize': `Bearer ` ; ; } // djinnServices.jsdjinn;djinn;djinnstart; // myPage.jsconst authService = djinn; const onStateUpdate = { console; // { token: { current: 'someNewTokenHere', previous: '' } } }; const unsubscribe = authService; authService;// onStateUpdate() called console; // { token: 'someNewTokenHere' } ; // Don't listen to changes anymore