PDA

View Full Version : event and return value?



Robert82
16 Jan 2011, 2:49 AM
Hello guys,
I've a little question about events and the return value.

Is it possible, that one component fires an event and expects a return value from the event listener?
Something like this:

Component 1


//inside the Component
//fire event
var returnValue = this.fireEvent(eventName, payload);
Component 2


//inside the Component
//process event function
return myReturnValue;

After that returnValue is equal to myReturnValue.

Like a request-response communication.
Currently, the fireEvent method delivers a boolean value.

Looking forward to your replies.
Regards

moegal
16 Jan 2011, 4:54 AM
you should be able to send any parameters you like with fireEvent

Condor
16 Jan 2011, 5:06 AM
No, fireEvent is not meant to return a value.

Returning 'false' from an event handler specifically specifies that any further event processing (you can attach more than one event handler) should be stopped and that 'false' should be returned from fireEvent.

If you want to return a value from an event handler than you should use a different method (e.g. set a property in the scope or use an array parameter).