featureEvents method
Listens to the stream of the native feature registered under
feature.
Implementation
@override
Stream<Object?> featureEvents(
String feature,
String stream,
Object? arguments,
) {
final id = _nextSubscriptionId++;
late final StreamController<Object?> controller;
controller = StreamController<Object?>(
onListen: () async {
_subscriptions[id] = controller;
try {
await _ensureHandlerInstalled();
await _invoke('feature.listen', {
'id': id,
'feature': feature,
'stream': stream,
'arguments': arguments,
});
} on ExtensionBridgeException catch (error, st) {
_subscriptions.remove(id);
controller.addError(error, st);
await controller.close();
}
},
onCancel: () async {
if (_subscriptions.remove(id) != null) {
await _invoke('feature.cancel', {'id': id});
}
},
);
return controller.stream;
}