This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"lastUpload":"2020-09-22T05:57:00.646Z","extensionVersion":"v3.4.3"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const productReducer = (state, action) => { | |
switch (action.type) { | |
case offlineActionTypes.FETCH_OFFLINE_MODE: | |
if ( | |
action.payload.prevAction.type === | |
actionTypes.FETCH_USER_SELECTED_PRODUCT_REQUEST | |
) { | |
return handleSelectedProductWhileOffline(state, action.payload); | |
} | |
return state; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const action = { | |
type: 'FETCH_USER_SELECTED_PRODUCT_REQUEST', | |
payload: { | |
id: 2 | |
}, | |
meta: { | |
retry: true | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type ActionToBeQueued = { | |
type: string, | |
payload?: any, | |
meta: { | |
retry?: boolean, // By passing true, your action will be enqueued on offline mode | |
dismiss?: Array<string> // Array of actions which, once dispatched, will trigger a dismissal from the queue | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type FetchOfflineModeActionForPO = { | |
type: '@@network-connectivity/FETCH_OFFLINE_MODE', | |
payload: { | |
prevAction: { | |
type: string, // Your previous action type | |
payload?: any, // Your previous payload | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
createNetworkMiddleware(config: MiddlewareConfig): ReduxMiddleware | |
type MiddlewareConfig = { | |
regexActionType?: RegExp = /FETCH.*REQUEST/, | |
actionTypes?: Array<string> = [], | |
queueReleaseThrottle?: number = 50, | |
shouldDequeueSelector: (state: RootReduxState) => boolean = () => true | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createStore, applyMiddleware } from 'redux'; | |
import { createNetworkMiddleware } from 'react-native-offline'; | |
import createSagaMiddleware from 'redux-saga'; | |
const sagaMiddleware = createSagaMiddleware(); | |
const networkMiddleware = createNetworkMiddleware({ | |
queueReleaseThrottle: 200, | |
}); | |
const store = createStore( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isConnectedSelector = state => state.network.isConnected; | |
const useNetworkInfo = () => { | |
const isConnected = useSelector(isConnectedSelector); | |
return [isConnected]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type NetworkState = { | |
isConnected: boolean, | |
actionQueue: Array<*> | |
} |
NewerOlder