authListener static method
Implementation
static Stream authListener() {
Stream nativeStream;
if (kIsWeb) {
//Stream<Event> jsStream = document.on["authChange"];
var jsStream = StreamInterop.getNativeStream("authChange");
// ignore: close_sinks
var controller = StreamController<Map?>();
controller.onListen = () {
controller.add(null);
};
// migrating events from the js-event to a dart event
jsStream.listen((event) {
Object? eventDetail = (event as CustomEvent).detail;
print(eventDetail);
if (eventDetail == null) {
controller.add(null);
} else {
var encode = json.encode(eventDetail);
controller.add(json.decode(encode));
}
});
nativeStream = controller.stream;
} else {
nativeStream = StreamInterop.getNativeStream({
"handler": "auth",
});
}
return nativeStream;
// return _streamsChannel.receiveBroadcastStream({
// "handler": "auth",
// });
}