49 lines
1.2 KiB
JavaScript
49 lines
1.2 KiB
JavaScript
|
/**
|
||
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||
|
* All rights reserved.
|
||
|
*
|
||
|
* This source code is licensed under the BSD-style license found in the
|
||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||
|
*
|
||
|
* @providesModule EventSubscription
|
||
|
* @typechecks
|
||
|
*/
|
||
|
|
||
|
'use strict';
|
||
|
|
||
|
/**
|
||
|
* EventSubscription represents a subscription to a particular event. It can
|
||
|
* remove its own subscription.
|
||
|
*/
|
||
|
|
||
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
|
||
|
|
||
|
var EventSubscription = (function () {
|
||
|
|
||
|
/**
|
||
|
* @param {EventSubscriptionVendor} subscriber the subscriber that controls
|
||
|
* this subscription.
|
||
|
*/
|
||
|
|
||
|
function EventSubscription(subscriber) {
|
||
|
_classCallCheck(this, EventSubscription);
|
||
|
|
||
|
this.subscriber = subscriber;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Removes this subscription from the subscriber that controls it.
|
||
|
*/
|
||
|
|
||
|
EventSubscription.prototype.remove = function remove() {
|
||
|
if (this.subscriber) {
|
||
|
this.subscriber.removeSubscription(this);
|
||
|
this.subscriber = null;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
return EventSubscription;
|
||
|
})();
|
||
|
|
||
|
module.exports = EventSubscription;
|