collection-sync-cache

1.9.2 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i collection-sync-cache

Weekly Downloads

2

Version

1.9.2

License

MIT

Last publish

Collaborators

  • lricoy