Replacing Redux Connect
Mapping state to props
import { combineLatest } from 'rxjs'
import { map } from 'rxjs/operators'
import { withEffects, toProps } from 'refract-rxjs'
import { getUser, getPosts } from './mySelectors'
const aperture = (component, initialProps) => {
const { store } = initialProps
const user$ = store.observe(getUser)
const posts$ = store.observe(getPosts)
return combineLatest(users$, posts$).pipe(
map(([user, posts]) => ({
user,
posts
})),
map(toProps)
)
}
const ContainerComponent = withEffects(aperture)(BaseComponent)Mapping action creators to props
Merging props
Last updated