[TIMOB-536] Firing custom events with data that includes a view causes listener to not listen
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Trivial |
Status | Closed |
Resolution | Duplicate |
Resolution Date | 2011-04-15T02:31:21.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | iOS |
Labels | 1.0, callback, custom, event |
Reporter | Noah |
Assignee | Reggie Seagraves |
Created | 2011-04-15T02:31:20.000+0000 |
Updated | 2017-03-09T21:20:40.000+0000 |
Description
Using SDK1.0
This Works:
Titanium.App.addEventListener('customEvent', function(e) {
Ti.API.debug("FIRED!");
});
Titanium.App.fireEvent('customEvent', {foo:'bar'});
But, this does not work. Event appears to fire (in console), but callback is never executed:
var tableView = Titanium.UI.createTableView();
Titanium.UI.currentWindow.add(tableView);
Titanium.App.addEventListener('customEvent', function(e) {
Ti.API.debug("FIRED!"); // never executed
});
Titanium.App.fireEvent('customEvent', {foo:tableView});
This also does not work, but perhaps is not expected to work. Event is never fired:
var tableView = Titanium.UI.createTableView();
Titanium.UI.currentWindow.add(tableView);
tableView.addEventListener('customEvent', function() {
Ti.API.debug("FIRED!"); // never executed
});
tableView.fireEvent('customEvent'); // never fires (according to console)
The documentation does in fact state that the event data must be JSON serializeable. That is not true in the second case, which is consistant with the documentation.
The third example however is expected to work based on the documentation that says it does. See Ticket #581.
Maybe I'm missing something, but why should example 3 work?
Surely the line
should be
put inside a
Noah
I take your point that the functionality is indeed in the docs, so my suggestion could be used as an alternative if anyone is having issues with implementing example 3. However, I am still not clear about the advantages of example 3. Is it just the tearing down that's mentioned in #581 ?
For the reason why example 2 doesn't work, see this http://developer.appcelerator.com/question/1221/passing-callback-with-fireevent"> Q&A
Therefore, I think this ticket is just a duplication of #581. I propose that it be closed.
Dupe of #581.
Closing ticket as invalid.