enforceReadPolicy method
void
enforceReadPolicy(
- Atom atom
)
Implementation
void enforceReadPolicy(Atom atom) {
// ---
// We are wrapping in an assert() since we don't want this code to execute at runtime.
// The dart compiler removes assert() calls from the release build.
// ---
assert(() {
switch (config.readPolicy) {
case ReactiveReadPolicy.always:
assert(_state.isWithinBatch || _state.isWithinDerivation,
'Observable values cannot be read outside Actions and Reactions. Make sure to wrap them inside an action or a reaction. Tried to read: ${atom.name}');
break;
case ReactiveReadPolicy.never:
break;
}
return true;
}());
}