12345678910111213141516171819202122232425262728293031323334 |
- const _ = require('lodash');
- const remx = require('remx');
-
- const state = remx.state({
- person: {
- name: 'no name'
- }
- });
-
- const setters = remx.setters({
- setName(newName) {
- state.person.name = newName;
- },
-
- setAge(age) {
- state.merge({ person: { age } });
- }
- });
-
- const getters = remx.getters({
- getName() {
- return _.get(state, ['person', 'name']);
- },
-
- getAge() {
- return _(state).get('person.age');
- }
- });
-
- module.exports = {
- setters,
- getters
- };
|