subscribeTo<T> method
BroadcastSubscription<T>
subscribeTo<T>(
- dynamic key,
- ValueChanged<
T?> onData, { - bool current = true,
- bool nullOk = true,
Subscribe to global object stream for given key
and Type.
onData
callback is triggered when broadcast with specified key
and correct value is called.
current
when object for given key
is stored from previous broadcast, then onData
is notified immediately.
Returns BroadcastSubscription to control and close subscription.
Implementation
BroadcastSubscription<T> subscribeTo<T>(
dynamic key,
ValueChanged<T?> onData, {
bool current = true,
bool nullOk = true,
}) {
assert(key != null);
return subscribe(
(data) => onData.call(data == null ? null : data as T),
current: current,
args: BroadcastSubscriptionArgs<T>(
key: key,
nullOk: nullOk,
),
) as BroadcastSubscription<T>;
}