Rxact React is a React observer for Rxact.
After setup this plugin, the instance of StateStream will have an observer function helping you binding stream's state to react component.
yarn add rxact rxact-react
There are two ways:
import{setup,StateStream}from'rxact'import{pluginasrxactReact}from'rxact-react'setup({Observable: /** Observable lib you like **/,plugins: [rxactReact()],})conststream=newStateStream('stream',{name: 'rxact'})stream.observer(state=>({name: state.name,}))(classReactComponentextendsReact.Component{
...
})import{setup,StateStream}from'rxact'import{decoratorasrxactReact}from'rxact-react'constEnhancedStateStream=decorator()(StateStream)setup({Observable: /** Observable lib you like **/,StateStream: EnhancedStateStream,})conststream=newEnhancedStateStream('stream',{name: 'rxact'})stream.observer(state=>({name: state.name,}))(classReactComponentextendsReact.Component{
...
})Return a StateStream plugin.
Return a function for wrapping StateStream.
stateStream.observer(mapStateToProps: ?Function,mergeProps: ?Function,): StateStreamPlugin| Parameter | Type | Description | Default |
|---|---|---|---|
| mapStateToProps | Function | Function for mapping stream state to component state. | None |
| mergeProps | Function | Function for merging result of mapStateToProps and parent props. | None |
If you are familiar with react-redux, you will find out it is almost as same as connect.