Rendering Components
Pushing Elements
import React from 'react'
import { withEffects } from 'refract-rxjs'
import { scan, startWith, map } from 'rxjs/operators'
const Counter = ({ count, addOne }) => <button onClick={addOne}>{count}</button>
const aperture = (component, { initialCount }) => {
const [addOneEvents$, addOne] = component.useEvent('addOne')
return addOneEvents$.pipe(
startWith({
count: initialCount,
addOne
}),
scan(({ count, ...props }) => ({
...props,
count: count + 1
})),
map(Counter)
)
}
export default withEffects(aperture)()Last updated