debugMetaStore.tsx 867 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import Reflux from 'reflux';
  2. const DebugMetaActions = Reflux.createActions(['updateFilter']);
  3. type State = {
  4. filter: string | null;
  5. };
  6. type DebugMetaStoreInterface = {
  7. get(): State;
  8. init(): void;
  9. reset(): void;
  10. updateFilter(word: string): void;
  11. };
  12. type Internals = {
  13. filter: string | null;
  14. };
  15. const storeConfig: Reflux.StoreDefinition & DebugMetaStoreInterface & Internals = {
  16. filter: null,
  17. init() {
  18. this.reset();
  19. this.listenTo(DebugMetaActions.updateFilter, this.updateFilter);
  20. },
  21. reset() {
  22. this.filter = null;
  23. this.trigger(this.get());
  24. },
  25. updateFilter(word) {
  26. this.filter = word;
  27. this.trigger(this.get());
  28. },
  29. get() {
  30. return {
  31. filter: this.filter,
  32. };
  33. },
  34. };
  35. const DebugMetaStore = Reflux.createStore(storeConfig);
  36. export {DebugMetaActions, DebugMetaStore};
  37. export default DebugMetaStore;