diff --git a/CHANGELOG.md b/CHANGELOG.md index d3d0d83..8cf13f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## `3.3.0` +Yay, `plugins` now support `wrappers` which is a segway onto HMR, time travel +and other cool plugins. These changes have come through in barracks `v8.3.0` +and a lil fix in `v8.3.1`. This is a lil patch before `4.0.0` comes through, +but should be super valuable. Wooh! + +### changes +- updated barracks to `v8.3.1` + ## `3.2.0` Wooh, `plugins` are a first class citizen now thanks to the `.use()` API. It's a multiplexed version of the old `app = choo(hooks)`. It should enable diff --git a/README.md b/README.md index c9c0c08..a3a04f1 100644 --- a/README.md +++ b/README.md @@ -400,7 +400,7 @@ DOM](#does-choo-use-a-virtual-dom). Sometimes it's necessary to change the way `choo` itself works. For example to report whenever an action is triggered, handle errors globally or perist state somewhere. This is done through something called `plugins`. Plugins are objects -that contain `hook` functions and are passed to `app.use()`: +that contain `hook` and `wrap` functions and are passed to `app.use()`: ```js const log = require('choo-log') @@ -423,7 +423,7 @@ frameworks a lot harder. Please exhaust all other options before using plugins.__ If you want to learn more about creating your own `plugins`, and which `hooks` -are available, head on over to [app.use()](#appusehooks). +and `wrappers` are available, head on over to [app.use()](#appusehooks). ## Badges Using `choo` in a project? Show off which version you've used using a badge: @@ -489,7 +489,7 @@ way `choo` works, adding custom behavior and listeners. Generally returning objects of `hooks` is done by returning them from functions (which we call `plugins` throughout the documentation). -There are several `hooks` that are picked up by `choo`: +There are several `hooks` and `wrappers` that are picked up by `choo`: - __onError(err, state, createSend):__ called when an `effect` or `subscription` emit an error. If no handler is passed, the default handler will `throw` on each error. @@ -497,6 +497,11 @@ There are several `hooks` that are picked up by `choo`: `action` is fired. - __onStateChange(data, state, prev, caller, createSend):__ called after a reducer changes the `state`. +- __wrapSubscriptions(fn):__ wraps a `subscription` to add custom behavior +- __wrapReducers(fn):__ wraps a `reducer` to add custom behavior +- __wrapEffects(fn):__ wraps an `effect` to add custom behavior +- __wrapInitialState(fn):__ mutate the complete initial `state` to add custom + behavior - useful to mutate the state before starting up __:warning: Warning :warning:: plugins should only be used as a last resort. It creates peer dependencies which makes upgrading versions and switching diff --git a/package.json b/package.json index bd199e2..d99ec18 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ ], "license": "MIT", "dependencies": { - "barracks": "^8.1.1", + "barracks": "^8.3.1", "document-ready": "~1.0.2", "global": "^4.3.0", "hash-match": "^1.0.2",