collection-sync-cache

A simple singleton approach to load and manage a single customizable collection for a resource


Keywords
proxy, cache
License
MIT
Install
bower install collection-sync-cache#v1.9.2

Documentation

Proxy-Cache

A simple singleton and proxy pattern approach to maintain a single customizable collection in the whole app

Travis Codecov npm

Installation

npm install collection-sync-cache --save

Usage

  import {Cache} from 'collection-sync-cache';
  let cache = new Cache();
  cache.syncObj({_id:1});

Middlewares

Pre Sync

  cache.preSync((obj) => {
     obj.customState = 'custom';
  });
  cache.syncObj({_id:1});

{_id: 1, customState: 'custom'}

Post Sync

  cache.postSynch((obj) => {
     console.log(`Just synched obj with _id ${obj._id}`);
  });
  cache.syncObj({_id:1});

Output: 'Just synched obj with _id 1

Tests

npm run test

Contributing

Take care to maintain the existing coding style. (Unless is shitty, It may be. Please tell me so) Add unit tests for any new or changed functionality. Lint and test your code. If I could do it, so can you. Use commitzen to commit. aka npm run commit