2016-05-16 11:04:37 +00:00
|
|
|
/**
|
2018-09-11 22:27:47 +00:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2016-05-16 11:04:37 +00:00
|
|
|
*
|
2018-02-17 02:24:55 +00:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2016-05-16 11:04:37 +00:00
|
|
|
*
|
2018-05-11 02:06:46 +00:00
|
|
|
* @format
|
2018-08-09 15:32:04 +00:00
|
|
|
* @flow strict-local
|
2016-05-16 11:04:37 +00:00
|
|
|
*/
|
2018-05-11 02:06:46 +00:00
|
|
|
|
2016-05-16 11:04:37 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
import type EventSubscriptionVendor from 'EventSubscriptionVendor';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* EventSubscription represents a subscription to a particular event. It can
|
|
|
|
* remove its own subscription.
|
|
|
|
*/
|
|
|
|
class EventSubscription {
|
|
|
|
eventType: string;
|
|
|
|
key: number;
|
|
|
|
subscriber: EventSubscriptionVendor;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {EventSubscriptionVendor} subscriber the subscriber that controls
|
|
|
|
* this subscription.
|
|
|
|
*/
|
|
|
|
constructor(subscriber: EventSubscriptionVendor) {
|
|
|
|
this.subscriber = subscriber;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes this subscription from the subscriber that controls it.
|
|
|
|
*/
|
|
|
|
remove() {
|
|
|
|
this.subscriber.removeSubscription(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = EventSubscription;
|