r-obj-model

0.0.1 • Public • Published

r-obj-model

Separation of Concerns

What does the library do?

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.

Why such a library?

To make separation of concern practical through composition easier than HoC.

What props are offered?

modelName: {
    hifu: {
        value: object,                        // state managed by the model.
    },
    hefu: {
        change: (newValue: object) => void,   // mergeDeepRight(value, newValue).
        reset: () => void,                    // reset value to initial.
    },
},

What props are expected?

ObjectModel optionally expects a prop called initial which provides initial object value.

In case it is not present, the initial value is set to {}.

How to use it?

Install the library

npm install --save r-obj-model

Import artefacts of the libary

import { connect } from 'r-socs-core';
import { ObjectModel } from 'r-obj-model';

Inject model props into consumer component

const NAME = 'NameOfService';

const ServicedComponent = connect(ObjectModel, NAME)(TargetComponent);

Use injected props

Injected props are just normal props.

Dependnecy:

{
    "r-socs-core": "^0.0.2",
    "ramda": "^0.26.1",
    "react": "^16.8.4"
}

Readme

Keywords

none

Package Sidebar

Install

npm i r-obj-model

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

12.8 kB

Total Files

15

Last publish

Collaborators

  • 1.riverside.swe