react-native-navigation的迁移库

Store.js 887B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. const _ = require('lodash');
  2. class Store {
  3. constructor() {
  4. this.propsByComponentId = {};
  5. this.componentsByName = {};
  6. this.refsById = {};
  7. }
  8. setPropsForComponentId(componentId, props) {
  9. _.set(this.propsByComponentId, componentId, props);
  10. }
  11. getPropsForComponentId(componentId) {
  12. return _.get(this.propsByComponentId, componentId, {});
  13. }
  14. setOriginalComponentClassForName(componentName, ComponentClass) {
  15. _.set(this.componentsByName, componentName, ComponentClass);
  16. }
  17. getOriginalComponentClassForName(componentName) {
  18. return _.get(this.componentsByName, componentName);
  19. }
  20. setRefForComponentId(id, ref) {
  21. _.set(this.refsById, id, ref);
  22. }
  23. getRefForComponentId(id) {
  24. return _.get(this.refsById, id);
  25. }
  26. cleanId(id) {
  27. _.unset(this.refsById, id);
  28. _.unset(this.propsByComponentId, id);
  29. }
  30. }
  31. module.exports = Store;