@vahesaroyan/redux-offline
TypeScript icon, indicating that this package has built-in type declarations

0.0.6 • Public • Published
yarn add @vahesaroyan/redux-offline
Fixed work for react native support

example:
import { createStore, applyMiddleware } from 'redux'
import AsyncStorage from '@react-native-community/async-storage'
import { composeWithDevTools } from 'redux-devtools-extension'
import { persistStore, persistReducer } from 'redux-persist'
import thunk from 'redux-thunk'
import reducer from '@/reducers'

import { createOffline } from '@vahesaroyan/redux-offline'
import offlineConfig from '@vahesaroyan/redux-offline/lib/defaults/index'

const persistConfig = {
  key: 'root',
  storage: AsyncStorage,
}

const {
  middleware: offlineMiddleware,
  enhanceReducer: offlineEnhanceReducer,
  enhanceStore: offlineEnhanceStore,
} = createOffline({
  ...offlineConfig,
  persist: false,
})

const persistedReducer = persistReducer(
  persistConfig,
  offlineEnhanceReducer(reducer),
)

const store = createStore(
  persistedReducer,
  composeWithDevTools(
    offlineEnhanceStore,
    applyMiddleware(thunk, offlineMiddleware),
  ),
)
const persistor = persistStore(store)

export { store, persistor }

Readme

Keywords

none

Package Sidebar

Install

npm i @vahesaroyan/redux-offline

Weekly Downloads

0

Version

0.0.6

License

MIT

Unpacked Size

95.8 kB

Total Files

55

Last publish

Collaborators

  • vahesaroyan