react-native-navigation的迁移库

remxStore.js 453B

1234567891011121314151617181920212223242526272829
  1. import _ from 'lodash';
  2. import * as remx from 'remx';
  3. export const state = remx.state({
  4. person: {
  5. name: 'no name'
  6. }
  7. });
  8. export const mutators = remx.setters({
  9. setName(newName) {
  10. state.person.name = newName;
  11. },
  12. setAge(age) {
  13. state.merge({person: {age}});
  14. }
  15. });
  16. export const selectors = remx.getters({
  17. getName() {
  18. return _.get(state, ['person', 'name']);
  19. },
  20. getAge() {
  21. return _(state).get('person.age');
  22. }
  23. });