cli

clientstore

Client Store is a library provides meaningful use of client side storages.

Showing:

Popularity

Downloads/wk

0

GitHub Stars

1

Maintenance

Last Commit

1mo ago

Contributors

1

Package

Dependencies

1

License

ISC

Type Definitions

Built-In

Tree-Shakeable

Yes?

Categories

Readme

ClientStore is a library provides meaningful use of client side storages.

You simply inject a ClientStore object in your constructor and store your data in an available client store Project initailly checks for Cookie availability then tries SessionStorage and LocalStorage options respectively. We can also give preferred storage options after injection.

Installation

npm install clientstore

Sample usecase

import { ClientStore, StoreOptions } from 'clientstore';

private storeSelection: StoreOptions[] = new Array<StoreOptions>(StoreOptions.Cookie, StoreOptions.Local);

@Injectable()
export class SomeService {
  constructor(private _clientContext: ClientStore) {
    this._clientContext.changeClientStore(this.storeSelection);  //optional
    this.loadFromCache();

    loadFromCache() {
      var cartCache = this._clientContext.get('shoppingList');
      if (cartCache != null && cartCache != "") {
        var cachedItems = JSON.parse(cartCache) as CartItemModel[];
        //this.loadCart(cachedItems);
      }
    }

    addToCart(pm: ProductModel) {
      this.items.push(cartItem);
      this.updateCache();
    }

    updateCache() {
      this._clientContext.save('shoppingList', JSON.stringify(this.items));
    }

  }

RELEASE NOTES

04/10/2019 High vulnurable risks are resolved, redundant dependecies are removed Please make your references thru dist folder and consider putting ClientStore under providers for Anuglar import { StoreOptions } from 'clientstore/dist/StoreOptions'; import { ClientStore } from 'clientstore/dist/ClientStore';

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100