-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update to work with marionette 1.0.0rc3 #8
Conversation
…ed require config so examples and tests still run
…ire config to correctly load them in...
…mplementation now available in backbone. Tests passing but example still broken...
…method. Example now seems to work the same as it did previously
Thanks so much for this, Kevin! This has been on my todo list ever since the new version of Backbone was released. I'll give it a whirl today and let you know how it goes for me. |
Cool - let me know if you have any questions. It seems to be working integrated into our (much) bigger project too :D |
Because Marionette.addEventBinder overwrites the toListen method to automatically _.bind the called method to a context then we can't pass the function in as the third argument to stopListening. This change means that things work as expected BUT it's not really safe. If the same object registered two different listeners to the same event then they would both be unsubscribed by this call rather than just the one we wanted to unsubscribe. I'm not sure that the proper solution is because Marionette doesn't allow expose the wrapped function. Any ideas?
Actually, please see the commit message on the added commit. The automatic cleaning up wasn't working quite as expected. I've put a workaround in place but I don't think it's the ideal solution and am interested in any improvements you can make. |
Yeah I tried this out yesterday and found that I was getting zombie views, and events not properly getting cleaned up. The solution I came up with is to embrace the "inversion of control" mechanism for event listening, introduced in the new Backbone API. Instead of Geppetto keeping track of listeners, we delegate to the view's built-in "listenTo" method and let the views keep track. When views are closed, their events are cleaned up. If a non-view wants to listen to a context, it can use |
Cool stuff! Would love to hear back on the new inversion of control mechanism for Geppetto and Marionette. |
@vitch: I wound up removing most of the code in @pheuter: Check out the changes and the updates to the README. Would love to hear your feedback as well! |
@geekdave - nice one :) I've integrated this into our codebase and it seems to be working great. The new approach makes much more sense too - nice one. And thanks for Geppetto btw - it's really helped keep our growing codebase rational... |
I've just updated marionette on a project using Geppetto and some things broke. Mostly because Marionette has now removed EventBinder (in favour of the listenTo methods now in Backbone). I've tried fixing them here and it seems to be working for the tests and examples in this project. Integrating it into our project now - I'll let you know how it goes there...