3.0.1 • Published 7 years ago

tiny-ng-store v3.0.1

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

Build status Build Status npm version

tiny-ng-store

A flexible store for Angular 2 projects. A tiny API and small footprint allow for a quick setup.

Docs

Use

Initialize

In your main app module

import { TinyNgStore } from 'tiny-ng-store/tiny-ng-store';

@NGModule({
    ...
    providers: [ TinyNgStore ]
    ...
})

Inject

import { TinyNgStore, StoreItem, TnsState } from 'tiny-ng-store/tiny-ng-store';

items: TnsState<any>;
constructor(private storeService: TinyNgStore) {};

Get Item

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.

Insert Item

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.

Update Item

this.storeService.UpdateItem({ name: 'storeName' data: 'Updated Data' });

Remove Item

this.storeService.DeleteItem('storeName');

Run tests

npm install
npm run tests
  • Runs Karma test runner and creates new results is the coverage/ folder.

Examples

Versions

3.0.1

  • Updated dependencies

3.0.0

Breaking:

  • Change TnsObservable to TnsState

Non-Breaking:

  • GetItem returns TnsState that utilizes distinctUntilChanged
  • Updated dependencies

2.0.0

Breaking:

  • Provide TnsObservable instead of Observable to prevent inheritance issues in RxJs
3.0.1

7 years ago

3.0.0

7 years ago

2.0.0

7 years ago

1.2.5

8 years ago

1.2.4

8 years ago

1.2.3

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.2

8 years ago

0.2.0

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago