New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

redux-offline-chain

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-offline-chain

chain as many offline actions as you like

  • 0.2.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
decreased by-61.9%
Maintainers
1
Weekly downloads
 
Created
Source

redux-offline-chain

A redux-middleware for redux-offline, inspired by redux-thunk.

redux-offline-chain allows you to chain offline actions. It looks for action.meta.then functions and invokes them in a redux-thunk like manner. The then callback gets the payload from the effect reconciler and optionally redux's dispatch and getState functions.

Caveat: Please note that the functions cannot be persisted and therefore only work within the same session.

Installation

$ npm install --save redux-offline-chain
import { applyMiddleware, compose, createStore, Store } from 'redux'
import { offline } from 'redux-offline'
import offlineConfig from 'redux-offline/lib/defaults'
import offlineChain from 'redux-offline-chain'

const store = offline(offlineConfig)(createStore)(
  rootReducer,
  compose(applyMiddleware(offlineChain))
)

Usage

type OfflineAction = {
  type: string,
  payload: any,
  meta: {
    offline: {
      effect: any,
      rollback: Action
      commit: {
        type: string,
        meta: {
+         then: Function,
        },
      },
    },
  }
}
export const actionCreator = payload => ({
  type: 'SOME_ACTION,'
  payload,
  meta: {
    offline: {
      effect: { path: '/some/endpoint' },
      rollback: { type: 'SOME_ACTION_ROLLBACK' },
      commit: {
        type: 'SOME_ACTION_COMMIT',
        meta: {
          then: payload => ({
            type: 'ANOTHER_ACTION',
            payload,
            meta: {
              offline: {
                effect: { path: '/another/endpoint', method: 'POST' },
                rollback: { type: 'ANOTHER_ACTION_ROLLBACK' },
                commit: {
                  type: 'ANOTHER_ACTION_COMMIT',
                  meta: {
                    then: payload => (dispatch, getState) => {
                      // ....
                    },
                  }
                },
              },
            },
          }),
        },
      },
    },
  },
})

Keywords

FAQs

Package last updated on 24 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc