once<T> method
Calls callback only the first time rx changes, then cancels.
once(isLoggedIn, (val) => analytics.trackFirstLogin());
Implementation
void once<T>(RxInterface<T> rx, void Function(T) callback) {
late StreamSubscription<T> sub;
sub = rx.listen((val) {
callback(val);
sub.cancel();
_workers.remove(sub);
});
_workers.add(sub);
}