broadcast<T> method
Sends value
to global object stream.
Subs with same key
and value
type will be notified.
store
- stores value
for future subs and notifies them immediately after subscribe.
Returns number of notified subs.
Implementation
int broadcast<T>({
dynamic key,
required dynamic value,
bool store = false,
}) {
key = Control.factory.keyOf<T>(key: key, value: value);
int count = 0;
if (store) {
_store[key] = value;
}
subs.cast<BroadcastSubscription>().forEach((sub) {
if (sub.isValidForBroadcast(key, value)) {
count++;
sub.notifyCallback(value);
}
});
return count;
}