use method
Subscribe to changes to this ProviderModel.
The callback passed here will be called whenever a ProviderModelVariable belonging to this ProviderModel
that was accessed inside the callback changes.
The callback will be called immediately once during execution of this function synchronously.
Do not call use inside of callback.
Do not do any sort of asynchronous work inside of callback.
Do not start any ProviderModelBatches inside of callback via begin or lock.
It should be used only to access data and not modify it.
Implementation
ProviderModelUseSubscription<T> use(void Function(T model) callback) {
assert(!_disposed, 'ProviderModel was already disposed.');
assert(
Zone.current[#providerModelUseSubscription] == null,
'use() cannot be called while a use callback is being executed.',
);
final tSubscription = ProviderModelUseSubscription<T>._(this, callback);
(_useSubscriptions ??= <ProviderModelUseSubscription<T>>[])
.add(tSubscription);
_executeUseSubscription(tSubscription);
return tSubscription;
}