构建面向 Web 和 React Native 的离线优先应用
招募维护者
为 Reasonaboutable:tm: 离线优先(Offline-First)应用提供持久化的 Redux 存储,并对乐观 UI(optimistic UI)提供一流支持。可与 React、React Native 配合使用,或作为任何 Web 应用的独立状态容器。
Redux Offline 现在由社区驱动的团队维护。该库的新版本将通过 npm 组织
@redux-offline发布。特别感谢 @jevakallio 最初创建了这么出色的库。
npm install --save @redux-offline/redux-offline@nativenpm install --save @redux-offline/redux-offline@exponpm install --save @redux-offline/redux-offlinecompose 添加 offline store 增强器
import { applyMiddleware, createStore, compose } from 'redux';
import { offline } from '@redux-offline/redux-offline';
import offlineConfig from '@redux-offline/redux-offline/lib/defaults';
// ...
const store = createStore(
reducer,
preloadedState,
compose(
applyMiddleware(middleware),
offline(offlineConfig)
)
);const followUser = userId => ({
type: 'FOLLOW_USER_REQUEST',
payload: { userId },
meta: {
offline: {
// the network action to execute:
effect: { url: '/api/follow', method: 'POST', json: { userId } },
// action to dispatch when effect succeeds:
commit: { type: 'FOLLOW_USER_COMMIT', meta: { userId } },
// action to dispatch if network action fails permanently:
rollback: { type: 'FOLLOW_USER_ROLLBACK', meta: { userId } }
}
}
});暂无开放 Issues,或尚未同步最近议题。