3.1.3 • Published 7 years ago
immview-react-connect v3.1.3
immview-react-connect
Functions to connect immview an Atom
or Observable
to a React component.
connect
is best for connecting many instances of the component to a single source
component
is best for more complex scenarios like connecting to multiple source or where a component instance is meant to make more calculations.
Installation
npm i immview-react-connect --save
component
usage
import { Atom, Combine } from 'immview'
import { component } from 'immview-react-connect'
import * as React from 'react'
const Chest = component(
(props$, state$) => (
state$.next({ 'open': 'trea' }),
state$.next({ 'sesame' : 'sure' }),
new Combine({
props: props$,
state: state$,
}).map(
({props, vault}) => (
<div>{
props.key.split('').map(key => state[key]).join('')
}</div>
)
)
)
)
const SecretDiscovererWithKey = () => (
<Chest key="open sesame" />
)
connect
usage
import { Atom } from 'immview'
import { connect } from 'immview-react-connect'
import * as React from 'react'
const Vault$ = new Atom({ 'open sesame': 'treasure' })
const SecretChest = connect(
({ children }) => (
<div>{children}</div>
),
Vault$,
(Vault, props) => ({
children: Vault[props.secretKey]
})
)
const SecretDiscovererWithKey = () => (
<SecretChest secretKey="open sesame" />
)
3.1.3
7 years ago
3.1.2
8 years ago
3.1.1
8 years ago
3.1.0
8 years ago
3.0.0
8 years ago
2.2.2
8 years ago
2.2.1
8 years ago
2.2.0
8 years ago
2.0.9
8 years ago
2.0.8
8 years ago
2.0.7
8 years ago
2.0.6
8 years ago
2.0.5
8 years ago
2.0.4
8 years ago
2.0.1
8 years ago
2.0.2
8 years ago
2.0.0
8 years ago
1.2.1
8 years ago
1.2.0
8 years ago
1.1.2
9 years ago
1.1.1
9 years ago
1.1.0
9 years ago
1.0.1
9 years ago
1.0.0
9 years ago