1.0.3 • Published 7 years ago

bdss v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
7 years ago

Brain Day State Service

Synopsis

An injectable service to provide a familiar and intuitive state container catered to Angular2.

Code Example

import { StoreService } from 'bdss';

  export class RenderTextComponent implements OnInit {
    private value: string;
    constructor(private store: StoreService) { }
    ngOnInit(): void {
        this.value = this.store.getState()['board'][this.id]
        this.store.subscribe(() => {
            this.value = this.store.getState()['board'][this.id]
        })
    }
}

Motivation

To simplify state management in angular2.

Installation

npm install bdss --save;

API Reference

addReducer(reducer: Function): void :Adds reducers to be run on state on invokation of DISPATCH.  

getState(): Object Returns a deep clone of state.

dispatch(action: Object): Object: Takes in action objects and checks for lock related commands before running state through reducers.

subscribe(fn: Function): Function : Subscribes a listener function to state changes and returns a function to unsubscribe the same listener function.

Tests

To Come ...

Contributors

github.com/eviscerare, github.com/soleiluwedu, github.com/ryanbas21

License

MIT

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago