Separation of Concerns
It provides a specific model/service to be used by a consumer component through injected props.
In other words, a component may use the model/service logic by connect it and through provided props.
To make separation of concern practical through composition easier than HoC.
modelName: {
hifu: {
value: object, // state managed by the model.
},
hefu: {
change: (newValue: object) => void, // mergeDeepRight(value, newValue).
reset: () => void, // reset value to initial.
},
},
ObjectModel optionally expects a prop called initial
which provides initial object value.
In case it is not present, the initial value is set to {}
.
npm install --save r-obj-model
import { connect } from 'r-socs-core';
import { ObjectModel } from 'r-obj-model';
const NAME = 'NameOfService';
const ServicedComponent = connect(ObjectModel, NAME)(TargetComponent);
Injected props are just normal props.
{
"r-socs-core": "^0.0.2",
"ramda": "^0.26.1",
"react": "^16.8.4"
}