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 |
|
11 | ;
|
12 |
|
13 | import type EventSubscriptionVendor from 'EventSubscriptionVendor';
|
14 |
|
15 | /**
|
16 | * EventSubscription represents a subscription to a particular event. It can
|
17 | * remove its own subscription.
|
18 | */
|
19 | class EventSubscription {
|
20 | eventType: string;
|
21 | key: number;
|
22 | subscriber: EventSubscriptionVendor;
|
23 |
|
24 | /**
|
25 | * @param {EventSubscriptionVendor} subscriber the subscriber that controls
|
26 | * this subscription.
|
27 | */
|
28 | constructor(subscriber: EventSubscriptionVendor) {
|
29 | this.subscriber = subscriber;
|
30 | }
|
31 |
|
32 | /**
|
33 | * Removes this subscription from the subscriber that controls it.
|
34 | */
|
35 | remove() {
|
36 | this.subscriber.removeSubscription(this);
|
37 | }
|
38 | }
|
39 |
|
40 | module.exports = EventSubscription;
|