Skip to content

Commit

Permalink
add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
IcculusC committed Aug 23, 2018
1 parent a187f67 commit 7ef9475
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 6 deletions.
85 changes: 80 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,82 @@
# fusion-plugin-created
# fusion-plugin-redux-thunk

You have created a Fusion.js universakl plugin.
Installs the [`redux-thunk`](https://github.com/reduxjs/redux-thunk) middleware for asynchronous dispatch.

* Run linters: yarn lint
* Run tests: yarn test
* Build the plugin: yarn transpile
---

### Table of contents

* [Installation](#installation)
* [Usage](#usage)
* [Setup](#setup)
* [API](#api)
* [Registration API](#registration-api)

---

### Installation
```js
yarn add fusion-plugin-redux-thunk
```

### Usage

Dispatch a thunk!

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

store.dispatch(imAThunk());
```

### Setup

```js
// 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`
```js
import ThunkEnhancer from 'fusion-plugin-redux-thunk';
```

The `redux-thunk` enhancer. Installs redux middleware. Typically registed to [`ThunkEnhancerToken`](#thunkenhancertoken)

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

Typically registered with [`ThunkEnhancer`](#thunkenhancer)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "fusion-plugin-redux-thunk",
"description": "FusionJS plugin for redux-thunk",
"version": "0.0.0",
"version": "0.1.1",
"license": "MIT",
"repository": "IcculusC/fusion-plugin-redux-thunk",
"main": "./dist/index.js",
Expand Down

0 comments on commit 7ef9475

Please sign in to comment.