sentryAppInstallationsStore.tsx 818 B

12345678910111213141516171819202122232425262728293031
  1. import {createStore} from 'reflux';
  2. import type {StrictStoreDefinition} from 'sentry/stores/types';
  3. import type {SentryAppInstallation} from 'sentry/types/integrations';
  4. interface SentryAppInstallationStoreDefinition
  5. extends StrictStoreDefinition<SentryAppInstallation[]> {
  6. load(items: SentryAppInstallation[]): void;
  7. }
  8. const storeConfig: SentryAppInstallationStoreDefinition = {
  9. state: [],
  10. init() {
  11. // XXX: Do not use `this.listenTo` in this store. We avoid usage of reflux
  12. // listeners due to their leaky nature in tests.
  13. this.state = [];
  14. },
  15. getState() {
  16. return this.state;
  17. },
  18. load(items: SentryAppInstallation[]) {
  19. this.state = items;
  20. this.trigger(items);
  21. },
  22. };
  23. const SentryAppInstallationStore = createStore(storeConfig);
  24. export default SentryAppInstallationStore;