EventSubscription.js 922 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. *
  7. * @format
  8. * @flow strict-local
  9. */
  10. 'use strict';
  11. import type EventSubscriptionVendor from './EventSubscriptionVendor';
  12. /**
  13. * EventSubscription represents a subscription to a particular event. It can
  14. * remove its own subscription.
  15. */
  16. class EventSubscription {
  17. eventType: string;
  18. key: number;
  19. subscriber: EventSubscriptionVendor;
  20. /**
  21. * @param {EventSubscriptionVendor} subscriber the subscriber that controls
  22. * this subscription.
  23. */
  24. constructor(subscriber: EventSubscriptionVendor) {
  25. this.subscriber = subscriber;
  26. }
  27. /**
  28. * Removes this subscription from the subscriber that controls it.
  29. */
  30. remove() {
  31. this.subscriber.removeSubscription(this);
  32. }
  33. }
  34. module.exports = EventSubscription;