Skip to content

Commit

Permalink
redux-routine: set up autogenerated API docs (#14228)
Browse files Browse the repository at this point in the history
  • Loading branch information
nosolosw committed Mar 8, 2019
1 parent 34240bc commit d67cf52
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bin/update-readmes.js
Expand Up @@ -27,7 +27,7 @@ const packages = [
'keycodes',
//'plugins',
'priority-queue',
//'redux-routine',
'redux-routine',
'rich-text',
'shortcode',
'url',
Expand Down
30 changes: 25 additions & 5 deletions packages/redux-routine/README.md
Expand Up @@ -57,19 +57,39 @@ request has completed does the action creator procede to return the `SET_TEMPERA

## API

### `createMiddleware( controls: ?Object )`
<!-- START TOKEN(Autogenerated API docs) -->

Create a Redux middleware, given an object of controls where each key is an action type for which to act upon, the value a function which returns either a promise which is to resolve when evaluation of the action should continue, or a value. The value or resolved promise value is assigned on the return value of the yield assignment. If the control handler returns undefined, the execution is not continued.
### default

[src/index.js#L19-L30](src/index.js#L19-L30)

Creates a Redux middleware, given an object of controls where each key is an
action type for which to act upon, the value a function which returns either
a promise which is to resolve when evaluation of the action should continue,
or a value. The value or resolved promise value is assigned on the return
value of the yield assignment. If the control handler returns undefined, the
execution is not continued.

**Parameters**

- **controls** `Object`: Object of control handlers.

**Returns**

`Function`: Co-routine runtime


<!-- END TOKEN(Autogenerated API docs) -->

## Motivation

`@wordpress/redux-routine` shares many of the same motivations as other similar generator-based Redux side effects solutions, including `redux-saga`. Where it differs is in being less opinionated by virtue of its minimalism. It includes no default controls, offers no tooling around splitting logic flows, and does not include any error handling out of the box. This is intended in promoting approachability to developers who seek to bring asynchronous or conditional continuation flows to their applications without a steep learning curve.

The primary motivations include, among others:

- **Testability**: Since an action creator yields plain action objects, the behavior of their resolution can be easily substituted in tests.
- **Controlled flexibility**: Control flows can be implemented without sacrificing the expressiveness and intentionality of an action type. Other solutions like thunks or promises promote ultimate flexibility, but at the expense of maintainability manifested through deep coupling between action types and incidental implementation.
- A **common domain language** for expressing data flows: Since controls are centrally defined, it requires the conscious decision on the part of a development team to decide when and how new control handlers are added.
- **Testability**: Since an action creator yields plain action objects, the behavior of their resolution can be easily substituted in tests.
- **Controlled flexibility**: Control flows can be implemented without sacrificing the expressiveness and intentionality of an action type. Other solutions like thunks or promises promote ultimate flexibility, but at the expense of maintainability manifested through deep coupling between action types and incidental implementation.
- A **common domain language** for expressing data flows: Since controls are centrally defined, it requires the conscious decision on the part of a development team to decide when and how new control handlers are added.

## Testing

Expand Down

0 comments on commit d67cf52

Please sign in to comment.