Redux Saga for CodePush
This module provides a "saga" for React Native apps that already use Redux and Redux Saga for modeling asynchronous behavior, and want to integrate code sychronization with the CodePush service via a simple, declarative solution.
Getting Started
-
If you haven't already, install and setup the React Native module for CodePush
-
Install the CodePush Redux Saga via NPM
npm i --save react-native-code-push-saga@latest -
Within your app's main saga, import the saga module
; -
Spawn/fork an instance of the CodePush saga
;
And that's it! By default, your app will now synchronize with CodePush on start, resume, and any time you dispatch a SYNC
action to your Redux store. If you want to customize the "sync points" (e.g. on a timer interval), delay syncing after the initial app store installation, or modify the options that are used when a sync occurs, you can pass additional parameters to the saga when spawning/forking. The following example illustrate some of the possibilities:
// Disable syncing on resume, but synchronize// with CodePush every 5 minutes. ; // Don't disrupt the user with an update after// initially installing the app, until either 10// minutes have passed or when the "ONBOARDING_COMPLETE"// action is dispatched. ; // Customize the install mode of updates// to occur when the app next resumes. ; // Synchronize with CodePush anytime// a Redux action named "NAVIGATE_HOME" is dispatched. ; // Invoke a callback every time the sync status changes// or show a status bar as the download progresses.// You can find a list of status types at// https://github.com/Microsoft/react-native-code-push#syncstatus. ;