diff --git a/README.md b/README.md index c7102950..36e8c022 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ The example below uses `refract-rxjs` to send data to localstorage. Every time the `username` prop changes, its new value is sent into the stream. The stream debounces the input for two seconds, then maps it into an object (with a `type` of `localstorage`) under the key `value`. Each time an effect with the correct type is emitted from this pipeline, the handler calls `localstorage.setItem` with the effect's `name` and `value` properties. ```js -const aperture = initialProps => component => { +const aperture = component => { return component.observe('username').pipe( debounce(2000), map(username => ({ @@ -104,7 +104,7 @@ const handler = initialProps => effect => { } } -const WrappedComponent = withEffects(handler)(aperture)(BaseComponent) +const WrappedComponent = withEffects(aperture, { handler })(BaseComponent) ``` ### Aperture diff --git a/base/__tests__/inferno/callbag/index.tsx b/base/__tests__/inferno/callbag/index.tsx index 3f397f49..d89af008 100644 --- a/base/__tests__/inferno/callbag/index.tsx +++ b/base/__tests__/inferno/callbag/index.tsx @@ -25,17 +25,16 @@ describe('refract-inferno-callbag', () => { } it('should create a HoC', () => { - const WithEffects = withEffects(handler)(aperture)( - () =>
- ) + withEffects(aperture, { handler })(() =>
) }) it('should observe component changes', () => { const effectValueHandler = jest.fn() const setValue = () => void 0 const WithEffects = withEffects( - () => effectValueHandler - )(aperture)(({ setValue, clickLink }) => ( + aperture, + { handler: () => effectValueHandler } + )(({ setValue, clickLink }) => (
) -const aperture = ({ initialCount }) => component => { +const aperture = (component, { initialCount }) => { component.observe('value').pipe(map(value => toProps({ doubledValue: 2 * value }))) } -const handler = () => () => {} - -export default withEffects(handler)(aperture)(DoubleValue) +export default withEffects(aperture)(DoubleValue) ``` ## Replacing Props @@ -60,7 +58,7 @@ import { scan, map } from 'rxjs/operators' const Counter = ({ count, addOne }) => -const aperture = ({ initialCount }) => component => { +const aperture = (component, { initialCount }) => { const [addOneEvents$, addOne] = component.useEvent('addOne') return addOneEvents$.pipe( @@ -78,7 +76,5 @@ const aperture = ({ initialCount }) => component => { ) } -const handler = () => () => {} - -export default withEffects(handler)(aperture)(Counter) +export default withEffects(aperture)(Counter) ``` diff --git a/docs/usage/rendering-components.md b/docs/usage/rendering-components.md index e63a3de2..dca84a79 100644 --- a/docs/usage/rendering-components.md +++ b/docs/usage/rendering-components.md @@ -22,7 +22,7 @@ import { scan, map } from 'rxjs/operators' const Counter = ({ count, addOne }) => -const aperture = ({ initialCount }) => component => { +const aperture = (component, { initialCount }) => { const [addOneEvents$, addOne] = component.useEvent('addOne') return addOneEvents$.pipe( @@ -40,7 +40,5 @@ const aperture = ({ initialCount }) => component => { ) } -const handler = () => () => {} - -export default withEffects(handler)(aperture)() +export default withEffects(aperture)() ```