![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
redux-storage
Advanced tools
npm install --save redux-storage
import storage from 'redux-storage'
import createEngine from 'redux-storage/engines/reactNativeAsyncStorage';
// You should know how to gather your reducers, as this part is plain redux :)
import { createStore, applyMiddleware } from 'redux';
import * as reducers from './reducers';
// Inject the storage reducer as first reducer in the whole chain/stack, as this
// will be the point where the loaded state will be "injected"
const reducer = storage.reducer(combineReducers(reducers));
// Now we need a engine that does the real load/save operation
let engine = createEngine('my-save-key');
// The middleware is required to detect changes and issue the save operations
const middleware = storage.createMiddleware(engine);
// Everything is ready now! Go ahead and use the store as usual, with the
// added benefit that every action will trigger a save operation :)
const store = applyMiddleware(middleware)(createStore)(reducer);
// Just create a loader function associated with your engine and you're ready
// to load the saved state into your store instance
const load = storage.createLoader(engine);
load(store);
redux-storage/engines/reactNativeAsyncStorage
This will use AsyncStorage
out of react-native
.
redux-storage/engines/localStorage
Stores everything inside window.localStorage
. Warning! localStorage
does
not expose a async API and every save/load operation will block the JS thread!
import { LOAD, SAVE } from 'redux-storage';
function storeageAwareReducer(state = { loaded: false }, action) {
switch (action.type) {
case LOAD:
return { ...state, loaded: true };
case SAVE:
console.log('Something has changed and written to disk!');
default:
return state;
}
}
Use this decorator to write only part of your state tree to disk.
import storage from 'redux-storage'
engine = storage.decorators.filter(engine, [
['some', 'key'],
['another', 'very', 'nested', 'key']
]);
This decorator will delay the expensive save operation for the given ms. Every new change to the state tree will reset the timeout!
import storage from 'redux-storage'
engine = storage.decorators.debounce(engine, 1500);
Convert parts of the state tree into ImmutableJS
objects on engine.load
.
import storage from 'redux-storage'
engine = storage.decorators.immutablejs(engine, [
['immutablejs-reducer'],
['plain-object-reducer', 'with-immutablejs-key']
]);
FAQs
Persistence layer for redux with flexible backends
The npm package redux-storage receives a total of 2,720 weekly downloads. As such, redux-storage popularity was classified as popular.
We found that redux-storage demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.