Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oakfang/redux-action-store
Save and load actions to persist state
https://github.com/oakfang/redux-action-store
Last synced: 20 days ago
JSON representation
Save and load actions to persist state
- Host: GitHub
- URL: https://github.com/oakfang/redux-action-store
- Owner: oakfang
- License: mit
- Created: 2016-01-13T09:35:45.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-01-13T10:11:04.000Z (about 9 years ago)
- Last Synced: 2024-11-09T18:19:13.370Z (3 months ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# redux-action-store
Save and load actions to persist state## Install for server-side use of redux
```
npm i redux-action-store
```## Simple usage
```js// store.js
'use strict';const redux = require('redux');
const app = require('./reducers');
const middleware = require('./middleware');
const ActionStore = require('redux-action-store');// attempt to load actions from JSON file, otherwise create a blank one
const actionStore = ActionStore.fromJson('./actions.json', app);
// add SIGINT and beforeExit hook to save back to JSON file
actionStore.setPersistence('./actions.json');
/*
You can also persist directly (sync) using: actionStore.toJson('./actions.json');
*/module.exports = redux.applyMiddleware(...middleware, actionStore.storeActions)(actionStore.createStore)();
```## Notes
- If using the `setPersistence` hooks, please make sure to exit explicitly on `CTRL-C`.
- As you should probably expect, replaying won't flare any side-effects (middleware).