How do I map an event to a views button
Hi guys Im new to robotlegs. I think im getting the hang of it,
so far Ive figured out how to map an view to mitigator, create a
custom event, creating a command that listens for that event and
fires the events payload off to a model or service from there a
service can dispatch an event back to the view. However im confused
about a few things. How can i just fire an event off from a button
press on a view. i.e. i press say a login in button on the view. In
the mitigator is there a way to map this straight to an event. I
could do it as follows but i think there is a better way that Im
not quite getting.
override public function onRegister():void
{
eventMap.mapListener(view.employeeLoginButton, MouseEvent.CLICK, empLoginClicked);
}
private function empLoginClicked(e:MouseEvent):void
{
dispatch(LoginEvent);
}
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 Ondina D.F. on 03 Apr, 2013 07:51 AM
Hi Joshua,
Hehe, Mitigator! Thanks for putting a smile on my face :)
The better way:
LoginView:
LoginMediator
LoginEvent
LoginEvent overrides clone(), so your mitigator can redispatch it, either like this:
or like this:
Does this help?
Ondina
2 Posted by Joshua Cave on 06 Apr, 2013 10:43 AM
This worked perfectly.. Thanks for your reply.. and yes the mediator made me laugh too because im pretty sure I called it a mitigator in front of my supervisor who is guiding/grooming me for a junior role. headsmack he probably knew i meant mediatior...
Support Staff 3 Posted by Ondina D.F. on 08 Apr, 2013 08:21 AM
Hey Joshua,
You’re welcome.
I’m sure your supervisor liked it. Mitigator sounds cool and original ;) It also adds a new perspective to the roles of Mediators. It alleviates Views’ situation: Views become well encapsulated, flexible, framework-agnostic, portable and reusable.
If I were you, I’d name my mediators SomeMitigator, AnotherMitigator, LoginMitigator, just for the fun of it.
Closing this discussion for now.
Ondina
Ondina D.F. closed this discussion on 08 Apr, 2013 08:21 AM.