remove method
Removes the element
from the registry.
Returns true
if removing the element succeeded, and false
if the
elements either wasn't in the registry, or it couldn't be removed.
The removeCapability
must be the same capability returned by add
when the object was added. If the capability is wrong, the
object is not removed, and this function returns false
.
Implementation
Future<bool> remove(T element, Capability removeCapability) {
var id = _cache.id(element);
if (id == null) {
// If the element is not in the cache, then it was not a value
// that originally came from the registry.
return Future<bool>.value(false);
}
var completer = Completer<bool>();
var port = singleCompletePort(completer, callback: (bool result) {
if (result) _cache.remove(id);
return result;
}, timeout: _timeout);
_commandPort.send(list4(_removeValue, id, removeCapability, port));
return completer.future;
}