remove method

Future<bool> remove(
  1. T element,
  2. Capability removeCapability
)

Remove the element from the registry.

Returns true if removing the element succeeded, or false if the elements wasn't in the registry, or if 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) {
    return Future<bool>.value(false);
  }
  var completer = Completer<bool>();
  var port = singleCompletePort(completer, callback: (bool result) {
    _cache.remove(id);
    return result;
  }, timeout: _timeout);
  _commandPort.send(list4(_removeValue, id, removeCapability, port));
  return completer.future;
}