Preload a view
Question
How do I make a view preload, as I need the event listeners to be mapped in advance..
Scenario
Im building a mobile application that has a list of objects as is start screen, when an object is clicked it loads a view with all that objects details. however, when i click the list I dispatch an event which is mapped to a command, Inside the command the view dispatches an event to a mediator on the main view bringing the details view into focus, however directly event is dispatched the model is updated with the selected object. this then causes the model to fire an event with the object payload telling the view to update. The problem is that that view mediator onregister() method with the event listener isn't happening before the the model event is dispatched so the details view isn't receiving the event with payload.
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by creynders on 06 May, 2013 07:20 AM
There's basically two options:
The mediator retrieves the selected object from the model. Or, if you don't want to inject models into mediators, the mediator dispatches a request, a command picks up the selected object and returns it to the mediator. (Either by dispatching an event, or the mediator could've passed some kind of responder object along with the request event, which the command populates)
You use the Relaxed Event Map. It allows for registering listeners after an event has been dispatched, exactly to solve situations like yours.
Support Staff 2 Posted by creynders on 16 May, 2013 09:36 AM
I'm closing this for now, if you have any more questions let us know!
creynders closed this discussion on 16 May, 2013 09:36 AM.