Skip to content

Connector improve

Latest
Compare
Choose a tag to compare
@icrosil icrosil released this 01 Jul 17:03
· 22 commits to master since this release

This release simplify store injection into component.

Now you have 2 extra methods: connectRemob and setConnector.

First of all set your connector (for example one that react-redux provides) with next line

import { setConnector } from 'remob';
import { connect } from 'react-redux';

setConnector(connect);

And now you able to connect stores to containers really easy:

// assume 3 stores already exist named 'store1', 'store2', 'store3'
import { connectRemob } from 'remob'
import store2 from '../stores/store2'

const Component = props => <YourAwesomeComponent {...props} />;

// string store
connectRemob('store1')(YourAwesomeComponent);
// instance store
connectRemob(store2)(YourAwesomeComponent);
// object store
connectRemob({ store4: store2 })(YourAwesomeComponent);

Changes you may find breakable:

Now combineRemob throws error if you pass remob with duplicating keys.