Startup & effects
This lab covers effects that wait for the UI, and the ones emitted before there is any UI to receive them.
Loading the demo…
Try it
Section titled “Try it”- Buffering. The controller emits a welcome effect in
onInit, before the page can listen. With Buffer effects on, the effect waits and a welcome message appears. Turn it off: the controller is recreated and the effect is lost. - Validation. Enter a name shorter than 3 characters and press Save name to see the failure reported through state. Enter a valid one to save it.
- A dialog with a result. Press Ask confirmation. The intent awaits the user’s answer through
emitAndWaitSideEffect; choose Yes or No and watch the status. If you wait, the call times out and reports No answer in time. - A missing handler. Press Trigger unhandled effect. No handler is registered for it, so the awaited result fails with a
StateErrorinstead of hanging, and the status line shows the failure.
The key line
Section titled “The key line”class SplashController extends JController<SplashState> { SplashController() : super(const SplashState(), effectBufferSize: 8);
@override void onInit() => emitSideEffect(ShowWelcome());}Details, including what happens when the buffer is full or the controller is disposed, are in the effects guide. The lab source shows the handler and the dialog helper.