A simple singleton and proxy pattern approach to maintain a single customizable collection in the whole app
npm install collection-sync-cache --save
import {Cache} from 'collection-sync-cache';
let cache = new Cache();
cache.syncObj({_id:1});
cache.preSync((obj) => {
obj.customState = 'custom';
});
cache.syncObj({_id:1});
{_id: 1, customState: 'custom'}
cache.postSynch((obj) => {
console.log(`Just synched obj with _id ${obj._id}`);
});
cache.syncObj({_id:1});
Output: 'Just synched obj with _id 1
npm run test
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