GithubHelp home page GithubHelp logo

redux-owl's Introduction

Redux Owl

Redux One Way Linking

This is a simple method for supporting offline sync. When two way concurrency such as scuttlebutt/CRDT is not possible (e.g. third party api's) or is not desired (complexity), this is a simple alternative.

The basic concept is, try to execute the action, on failure add it to a retry queue. Every so often process the retry queue until success is achieved.

To function properly your app will also need to support the following:

@TODO

improve api (reducer vs store enhancer?) add processing rules

  • configurable per action retry back off
  • configurable processing (interval, network monitor)
  • should process ever accelerate back off schedule? e.g. network monitor returns true
  • extract basic retry action logic into seperate module. Have owl focus more on the network layer.

Setup

import {owlReducer, enableOwl} from 'redux-owl'
import {persistStore} from 'redux-persist'

const reducer = combineReducers({
  ...otherReducers,
  owl: owlReducer,
})

//...

persistStore(store, {}, (err) => {
  //does not depend on redux-persist, but be sure enable owl
  //after persistence is complete
  enableOwl(store, {})
})

ActionCreator

import {createOwlAction } from 'redux-owl'

export function createRecordTest(record) {
  return createOwlAction('RECORD_INSERT', record, {})
}

Async Action / Side Effects

import { remoteActionMap } from 'redux-remotes'
import { handleOwlAction } from 'redux-owl'

export default remoteActionMap({
  RECORD_INSERT({action, getState, dispatch, finish}){
    handleOwlAction(action, finish, (success, fail) => {
      if(Math.random() > .5){ setTimeout(success, 1000) }
      else { setTimeout(fail, 1000) }
    })
  }
})

redux-owl's People

Contributors

rt2zz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.