
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@app-masters/sync-cache
Advanced tools
## Description Classes for deal with local persistence of data and online synchronization Sync deals with external API and duplicate the data to redux store. At the same time, can have unsynchronized data on local storage.
Classes for deal with local persistence of data and online synchronization Sync deals with external API and duplicate the data to redux store. At the same time, can have unsynchronized data on local storage.
On the App.js
, import and give desired model list to setup./
import { AmSync, AmSyncCache } from '@app-masters/sync-cache';
...
// Custom conflict rule (Priories newest object)
const conflictRule = (cacheObject, onlineObject) => {
const dateCache = new Date(cacheObject.updatedAt).getDate();
const dateOnline = new Date(onlineObject.updatedAt).getDate();
if (dateCache < dateOnline) {
return onlineObject;
} else {
return cacheObject;
}
};
// Default config for USER actions
const userReduxConfig = {
validateObject: () => {}, // required
prepareToServer: (item) => item,
prepareToClient: (item) => item,
conflictRule: conflictRule,
typePrefix: 'USER', // required
endPoint: '/users/', // required
cacheStrategy: 'CacheOnline',
createSuffix: '',
updateSuffix: '',
deleteSuffix: '',
primaryKey: '_id'
};
AmSyncCache.setStorage(storage); // using @app-masters/realm-async-storage
const UserActions = new AmSync(userReduxConfig);
Most of the methods are called by redux as redux-thunk
actions.
For synchonization, some methods are available on each instance, not requiring to be called as a redux action.
_cacheCreatedAt
and sync it with API_cacheUpdatedAt
and sync it with API_cacheDeletedAt
and sync it with APIFor running the tests, you can run a local API for integration tests. On another CLI, make API available on port 3000 with running the script:
$ cd api
$ npm run dev
[0.3.17/0.3.18] - 2018-10-29
FAQs
## Description Classes for deal with local persistence of data and online synchronization Sync deals with external API and duplicate the data to redux store. At the same time, can have unsynchronized data on local storage.
The npm package @app-masters/sync-cache receives a total of 4 weekly downloads. As such, @app-masters/sync-cache popularity was classified as not popular.
We found that @app-masters/sync-cache demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.