fusion-plugin-redux-thunk

0.1.1 • Public • Published

fusion-plugin-redux-thunk

Installs the redux-thunk middleware for asynchronous dispatch.


Table of contents


Installation

yarn add fusion-plugin-redux-thunk

Usage

Dispatch a thunk!

const imAThunk = () =>
    dispatch => {
        dispatch({ type: 'IM_A_THUNK' });
        setTimeout(() => dispatch({ type: 'HES_A_THUNK' }));
    };

store.dispatch(imAThunk());

Setup

// main.js
import React from 'react';
import Redux, {
  ReduxToken,
  ReducerToken,
  EnhancerToken,
  GetInitialStateToken,
} from 'fusion-plugin-react-redux';
import ThunkEnhancer, { ThunkEnhancerToken } from 'fusion-plugin-redux-thunk';
import App from 'fusion-react';
import { createPlugin } from 'fusion-core';
import { compose } from 'redux';
import reducer from './reducer';

export default () => {
  const app = new App(root);
  app.register(ReduxToken, Redux);
  app.register(ReducerToken, reducer);
  app.register(ThunkEnhancerToken, ThunkEnhancer);
  app.register(EnhancerToken, createPlugin({
    deps: { thunkEnhancer: ThunkEnhancerToken },
    provides: ({ thunkEnhancer }) => compose(thunkEnhancer),
  }));
  __NODE__ && app.register(GetInitialStateToken, async ctx => ({}));
}

API

Registration API

ThunkEnhancer
import ThunkEnhancer from 'fusion-plugin-redux-thunk';

The redux-thunk enhancer. Installs redux middleware. Typically registed to ThunkEnhancerToken

ThunkEnhancerToken
import { ThunkEnhancerToken } from 'fusion-plugin-redux-thunk';

Typically registered with ThunkEnhancer

Readme

Keywords

none

Package Sidebar

Install

npm i fusion-plugin-redux-thunk

Weekly Downloads

0

Version

0.1.1

License

MIT

Unpacked Size

24.8 kB

Total Files

19

Last publish

Collaborators

  • icculusc