emitExpression method
Notifies the UI of a state change (loading, success, error). The UI listens to expressions.
Why use it: The UI doesn't ask "are you loading?"; the flow announces state.
Example: emitExpression("loading"); then emitExpression("success", payload: user);
Implementation
void emitExpression(String type, {dynamic payload}) {
if (kDebugMode) {
final c = _cachedContract;
if (c != null && !c.allowsExpression(type)) {
debugPrint(
'OmegaFlow[$id]: emitted expression type "$type" not in contract (allowed: ${c.emittedExpressionTypes}).',
);
}
}
if (!_expressions.isClosed) {
final expr = OmegaFlowExpression(type, payload: payload);
_lastExpression = expr;
_expressions.add(expr);
}
}