onBroadcastMessage property
Returns a stream broadcasting the browser's broadcast channel changes.
Implementation
static Stream<dynamic> get onBroadcastMessage {
StreamController<dynamic>? controller;
final channel = web.BroadcastChannel('fcm');
controller = StreamController(
onListen: () {
void fn(web.Event e) =>
controller?.add((e as web.MessageEvent).data.dartify());
channel.onmessage = fn.toJS;
},
onCancel: () => channel.onmessage = null,
);
return controller.stream;
}