Giter Site home page Giter Site logo

react-native-code-push-saga's Introduction

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

  1. If you haven't already, install and setup the React Native module for CodePush

  2. Install the CodePush Redux Saga via NPM

    npm i --save react-native-code-push-saga@latest
  3. Within your app's main saga, import the saga module

    import codePushSaga from "react-native-code-push-saga";
  4. Spawn/fork an instance of the CodePush saga

    yield spawn(codePushSaga);

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.
yield spawn(codePushSaga, {
    syncOnResume: false,
    syncOnInterval: 5 * 60
});

// 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.
yield spawn(codePushSaga, {
    delayByInterval: 10 * 60,
    delayByAction: "ONBOARDING_COMPLETE"
});

// Customize the install mode of updates
// to occur when the app next resumes.
yield spawn(codePushSaga, {
    syncOptions: {
        installMode: codePush.InstallMode.ON_NEXT_RESUME
    }
});

// Synchronize with CodePush anytime
// a Redux action named "NAVIGATE_HOME" is dispatched.
yield spawn(codePushSaga, {
   syncActionName: "NAVIGATE_HOME" 
});

react-native-code-push-saga's People

Contributors

lostintangent avatar xxsnakerxx avatar duranmla avatar

Watchers

Ben Yee avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.