Releases: icrosil/remob
Connector improve
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.
Action with func powers!
So from this point actions are now access funs in first argument to dynamically change what part of store you would like to change!
// functions supported, more dynamic for your needed flow
@action(state => (Math.random() > 0.5 ? 'field' : 'deep.field')) changeRandomPart(state) {
return Math.random();
}
Debugging
@action support
Added new feature for action creators.
Now @action supported and works just as @action().
This will produce all new state.
Nested actions added
From 0.2.1 version action path could be nested!
Consider next example
import { Reducer, action } from remob;
class Counter extends Reducer {
initialState = {
deep: {
field: 42,
}
};
// deep path exist, _.get powered.
@action('deep.field') incrementDeepField(state) {
return state.deep.field + 1;
}
}
export default new Counter();
Field path will be used with _.get method, so object or array would work as is.