A flexible store for Angular 2 projects. A tiny API and small footprint allow for a quick setup.
import { TinyNgStore } from 'tiny-ng-store/tiny-ng-store';
@NGModule({
...
providers: [ TinyNgStore ]
...
})
import { TinyNgStore, StoreItem, TnsState } from 'tiny-ng-store/tiny-ng-store';
items: TnsState<any>;
constructor(private storeService: TinyNgStore) {};
this.storeService.GetItem('storeName')
-
Returns a StoreItem TnsState - Map to extract data, tansform, or subscribe as necessary
this.storeService.GetItem('storeName').map((s: StoreItem) => s && s.data);
-
This will return a TnsState that contains either undefined (if it was never created) or the data you added to that store.
this.storeService.InsertItem({ name: 'storeName' data: 'Any Data' });
-
Use any type of data that you want
-
Returns a StoreItem TnsState - Map to extract data, tansform, or subscribe as necessary
this.storeService.InsertItem('storeName').map((s: StoreItem) => s && s.data);
-
This will return a TnsState that contains the data added to that store.
this.storeService.UpdateItem({ name: 'storeName' data: 'Updated Data' });
this.storeService.DeleteItem('storeName');
npm install
npm run tests
- Runs Karma test runner and creates new results is the coverage/ folder.
-
A collection of small examples for various Angular 2 items https://github.com/JScearcy/angular-2-examples
-
The tiny-ng-store examples https://github.com/JScearcy/angular-2-examples/tree/master/src/app/tiny-ng-store-example
- Updated dependencies
Breaking:
- Change TnsObservable to TnsState
Non-Breaking:
- GetItem returns TnsState that utilizes distinctUntilChanged
- Updated dependencies
Breaking:
- Provide TnsObservable instead of Observable to prevent inheritance issues in RxJs