Skip to content

A simple approach to maintain a single customizable collection

License

Notifications You must be signed in to change notification settings

lricoy/proxy-cache

Repository files navigation

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

About

A simple approach to maintain a single customizable collection

Resources

License

Stars

Watchers

Forks

Packages

No packages published