RL2: Async configurations

77 views
Skip to first unread message

Joni Bekenstein

unread,
May 15, 2012, 10:19:33 AM5/15/12
to robo...@googlegroups.com
So I thought I could add a configuration to a context which would register an async handler to context.lifecycle.whenInitializing...

Then I found this comment in LifeCycle class: When and After handlers can not be asynchronous

My configuration loads an external file to do it's configuration stuff, and I want to pause the initialization flow until this configuration is done. How can I achieve that? Is it a bad approach to do this job in a configuration?

Shaun Smith

unread,
May 18, 2012, 11:20:39 AM5/18/12
to robo...@googlegroups.com
Yeh, it's a tricky one. Initially we allowed async "when" and "after" handlers but decided in the end that it was a bad idea. It felt awkward that once a state had successfully been entered into, there was a possibility that some async process would be lingering around in the background. Further state changes would then be possible with multiple async handler chains running against old states.

Another feature of the async handler pattern is the ability to halt with an error which prevents the transition from happening, but again this didn't make any sense once a state had already been entered into. The only sensible approach was to allow "before" handlers to be asynchronous and prevent transitions, but leave the "when" and "after" phases as pure observables.

So, I'd be tempted to say that context initialization should only revolve around setting up required extensions, and that any application specific async processes should only be kicked off after initialization. Could you provide more details of your use-case (you can mail me off-list if need be) so I can think about it some more? Alternatively, you can open an issue on GitHub in case anyone else wants to get involved.

--
You received this message because you are subscribed to the Google
Groups "Robotlegs" group.
To post to this group, send email to robo...@googlegroups.com
To unsubscribe from this group, send email to
robotlegs+...@googlegroups.com
for support visit http://knowledge.robotlegs.org

Reply all
Reply to author
Forward
0 new messages