@phosphor/signaling
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -161,2 +161,15 @@ /** | ||
/** | ||
* Remove all connections between a sender and receiver. | ||
* | ||
* @param sender - The sender object of interest. | ||
* | ||
* @param receiver - The receiver object of interest. | ||
* | ||
* #### Notes | ||
* If a `thisArg` is provided when connecting a signal, that object | ||
* is considered the receiver. Otherwise, the `slot` is considered | ||
* the receiver. | ||
*/ | ||
function disconnectBetween(sender: any, receiver: any): void; | ||
/** | ||
* Remove all connections where the given object is the sender. | ||
@@ -179,2 +192,13 @@ * | ||
/** | ||
* Remove all connections where an object is the sender or receiver. | ||
* | ||
* @param object - The object of interest. | ||
* | ||
* #### Notes | ||
* If a `thisArg` is provided when connecting a signal, that object | ||
* is considered the receiver. Otherwise, the `slot` is considered | ||
* the receiver. | ||
*/ | ||
function disconnectAll(object: any): void; | ||
/** | ||
* Clear all signal data associated with the given object. | ||
@@ -185,6 +209,6 @@ * | ||
* #### Notes | ||
* This removes all signal connections where the object is used as | ||
* either the sender or the receiver. | ||
* This removes all signal connections and any other signal data | ||
* associated with the object. | ||
*/ | ||
function clearData(object: any): void; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/*----------------------------------------------------------------------------- | ||
@@ -115,2 +116,18 @@ | Copyright (c) 2014-2017, PhosphorJS Contributors | ||
/** | ||
* Remove all connections between a sender and receiver. | ||
* | ||
* @param sender - The sender object of interest. | ||
* | ||
* @param receiver - The receiver object of interest. | ||
* | ||
* #### Notes | ||
* If a `thisArg` is provided when connecting a signal, that object | ||
* is considered the receiver. Otherwise, the `slot` is considered | ||
* the receiver. | ||
*/ | ||
function disconnectBetween(sender, receiver) { | ||
Private.disconnectBetween(sender, receiver); | ||
} | ||
Signal.disconnectBetween = disconnectBetween; | ||
/** | ||
* Remove all connections where the given object is the sender. | ||
@@ -139,2 +156,16 @@ * | ||
/** | ||
* Remove all connections where an object is the sender or receiver. | ||
* | ||
* @param object - The object of interest. | ||
* | ||
* #### Notes | ||
* If a `thisArg` is provided when connecting a signal, that object | ||
* is considered the receiver. Otherwise, the `slot` is considered | ||
* the receiver. | ||
*/ | ||
function disconnectAll(object) { | ||
Private.disconnectAll(object); | ||
} | ||
Signal.disconnectAll = disconnectAll; | ||
/** | ||
* Clear all signal data associated with the given object. | ||
@@ -145,8 +176,7 @@ * | ||
* #### Notes | ||
* This removes all signal connections where the object is used as | ||
* either the sender or the receiver. | ||
* This removes all signal connections and any other signal data | ||
* associated with the object. | ||
*/ | ||
function clearData(object) { | ||
Private.disconnectSender(object); | ||
Private.disconnectReceiver(object); | ||
Private.disconnectAll(object); | ||
} | ||
@@ -219,3 +249,3 @@ Signal.clearData = clearData; | ||
var receivers = receiversForSender.get(signal.sender); | ||
if (!receivers) { | ||
if (!receivers || receivers.length === 0) { | ||
return false; | ||
@@ -241,2 +271,36 @@ } | ||
/** | ||
* Remove all connections between a sender and receiver. | ||
* | ||
* @param sender - The sender object of interest. | ||
* | ||
* @param receiver - The receiver object of interest. | ||
*/ | ||
function disconnectBetween(sender, receiver) { | ||
// If there are no receivers, there is nothing to do. | ||
var receivers = receiversForSender.get(sender); | ||
if (!receivers || receivers.length === 0) { | ||
return; | ||
} | ||
// If there are no senders, there is nothing to do. | ||
var senders = sendersForReceiver.get(receiver); | ||
if (!senders || senders.length === 0) { | ||
return; | ||
} | ||
// Clear each connection between the sender and receiver. | ||
algorithm_1.each(senders, function (connection) { | ||
// Skip connections which have already been cleared. | ||
if (!connection.signal) { | ||
return; | ||
} | ||
// Clear the connection if it matches the sender. | ||
if (connection.signal.sender === sender) { | ||
connection.signal = null; | ||
} | ||
}); | ||
// Schedule a cleanup of the senders and receivers. | ||
scheduleCleanup(receivers); | ||
scheduleCleanup(senders); | ||
} | ||
Private.disconnectBetween = disconnectBetween; | ||
/** | ||
* Remove all connections where the given object is the sender. | ||
@@ -298,2 +362,22 @@ * | ||
/** | ||
* Remove all connections where an object is the sender or receiver. | ||
* | ||
* @param object - The object of interest. | ||
*/ | ||
function disconnectAll(object) { | ||
// Clear and cleanup any receiver connections. | ||
var receivers = receiversForSender.get(object); | ||
if (receivers && receivers.length > 0) { | ||
algorithm_1.each(receivers, function (connection) { connection.signal = null; }); | ||
scheduleCleanup(receivers); | ||
} | ||
// Clear and cleanup any sender connections. | ||
var senders = sendersForReceiver.get(object); | ||
if (senders && senders.length > 0) { | ||
algorithm_1.each(senders, function (connection) { connection.signal = null; }); | ||
scheduleCleanup(senders); | ||
} | ||
} | ||
Private.disconnectAll = disconnectAll; | ||
/** | ||
* Emit a signal and invoke its connected slots. | ||
@@ -300,0 +384,0 @@ * |
{ | ||
"name": "@phosphor/signaling", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "PhosphorJS - Signals and Slots", | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/phosphorjs/phosphor.git" | ||
}, | ||
"files": [ | ||
@@ -15,8 +11,20 @@ "lib/*.d.ts", | ||
], | ||
"dependencies": { | ||
"@phosphor/algorithm": "^0.1.0" | ||
}, | ||
"directories": { | ||
"lib": "lib/" | ||
}, | ||
"dependencies": { | ||
"@phosphor/algorithm": "^0.1.1" | ||
}, | ||
"devDependencies": { | ||
"rimraf": "^2.5.2", | ||
"typescript": "^2.2.1" | ||
}, | ||
"scripts": { | ||
"build": "tsc", | ||
"clean": "rimraf lib" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/phosphorjs/phosphor.git" | ||
}, | ||
"author": "S. Chris Colbert <sccolbert@gmail.com>", | ||
@@ -23,0 +31,0 @@ "contributors": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
24680
700
0
2
Updated@phosphor/algorithm@^0.1.1