Menu

Why bloc.add(...) Isn't What You Think: Synchronous Event Fast-Paths and 0ms Form Bindings
πŸ“°

Why bloc.add(...) Isn't What You Think: Synchronous Event Fast-Paths and 0ms Form Bindings

DEV Community: dartΒ·Randal L. SchwartzΒ·about 19 hours ago
#NVEg7v7r
#devtodart#devto#dev#event#bloc
Reading 0:00
15s threshold

The Muscle-Memory Illusion

"An asynchronous network stream belongs at the perimeter of your architecture; once an AI agent's UI lands on the client, every keystroke, validation rule, and leaf rebuild must execute in 0ms on a synchronous signal graph."

β€” Randal L. Schwartz

When Flutter developers inspected the code samples from our bloc_signals_genui 1.0 announcement , their classic package:bloc muscle memory sparked an immediate question:

// Mutate bound form fields synchronously in 0ms surfaceBloc . add ( const UpdateFormField ( path: '/user/name' , value: 'Randal L. Schwartz' , ), );

Enter fullscreen mode

Exit fullscreen mode

The question went something like this: Wait. It is called a Bloc and you are calling .add(event) . Doesn't that push the event into an asynchronous StreamController sink, schedule a microtask on the Dart event loop, sever the call stack, and update the UI in a later frame?

In BlocSignal , .add() dispatches events synchronously on the active call stack.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.