-
Notifications
You must be signed in to change notification settings - Fork 255
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
multiple instance of Todos #25
Comments
Good catch. Maybe we need a way to check the status if a widget in the
|
I think exposing the status makes sense. started, stopped - anything else? |
@dustinboston I believe a similar issue was mentioned on another ticket. Should we be explicitly storing widget state? If so, where should this be stored? data? internal cache? |
@yapcheahshen - Can you clarify? I know this was a while ago, are you still experiencing the issue? |
@yapcheahshen Video! Awesome! We'll expose the status and wrap the calls with a check for a loaded widget. Do you want to take a shot at it and send a Pull Request? |
@yapcheahshen ping, in case you're interested. If not, we'll try to assign to another member of the team that might be interested. |
@addyosmani i am not quite understood, how could i contribute ? regards, 2012/8/18 Addy Osmani notifications@github.com
|
@yapcheahshen Oh! So, the way Github works is quite straight-forward. On the main page of this project you'll see a button to the right called 'fork'. Clicking it will create a version of the project on your GitHub account that you can then edit. You would create a local clone of this (using See https://help.github.com/articles/fork-a-repo and https://help.github.com/articles/using-pull-requests/ |
thanks for your instruction, i fork and clone a local copy of backbone-aura. i can prevent multiple instance of todo item by adding one line in initialize: function () { but i think this is only a quick hack and not generally a good practice, regards, 2012/8/18 Addy Osmani notifications@github.com
|
@yapcheahshen if you're still interested in putting together a pull request, we'd definitely be interested in you exploring this further :) |
We don't at present, but could certainly do something like that. Would it make sense to just store references with a type of hash/ID/sha or something similar rather than count? We could then check to see if a single instance existed and handle appropriately. would that work? |
yes, object references is better, regards, 2012/8/25 Addy Osmani notifications@github.com
|
Hey Guys!!! I was revisiting this problem just now. And I think it is bigger than it seems. On /src/widgets/todos/views/app.js line 25 the "initialize" function of the todos "AppView" binds a few events to the Todos Collection and to the sandbox every time this view is initialized (on start). That causes three problems: The first is the one already described (even with video :D ) by @yapcheahshen, creating an extra entry of a todo for as many times as you click the "Start Todos" button. So let's say we click it three times, you'll get three entries of each todo. The second is that the same thing happens when you add a new todo. (Say that you click the "Start Todos" button three times. Than you create a new todo, this new todo will be inserted in the list three times). The third is not noticeable, but when you reset the todos, it also gets reset three times. The reason why it happens is because the events "add", "reset" and "all" were bound three times to the Todo collection, the same way the listeners "new-event" and "todos" were added three times to the sandbox (not sure te impact it causes though). Now that we have a little better understanding of the problem we could say that this is not exactly a bug in the todo app, but that something is lacking in Aura's architecture. We have a situation where widgets may re-bind events that were already bound. Now, why is this situation happening? Should aura have unbound events when the widget was stopped? Should it have completely got rid of all widget objects (Collections, Models, etc of the widget on stop)? Or should it simply prevent widgets of binding the same event with the same channel and subscriber more than once? I'm really not sure which way to go. But I believe we must solve this issue before we can call Aura ready for prime time (v1). |
As far as "opinionated" goes, Aura could simply prevent the same widget from subscribing to the same channel more than once (your very last suggestion). I don't know if that could lead to laziness on the developers part, and lead to other problems down the line though... Or perhaps widget-to-widget subscription could be made declarative, so it's entirely managed by Core... |
I would be tempted for us to opt for this option in the short term and explore whether there's a more solid solution that can avoid problems with laziness/confusion long-term. |
@atesgoral, @addyosmani, thinking about this it seems to me that @dustinboston 's first suggestion that
would be a cleaner solution for this problem. This way we would never start a widget instance more than once. Having one sandbox per instance of a widget, the sandbox could do this check if the widget is already start and prevent restart. That solves one problem. But the fact that all that baggage of Models and Collections are still around (in the memory) after a widget has been stopped is bothering me big time. Let's say that we did not have the start/stop controls and that the todo widget was being stopped by the application because really it's not necessary anymore. All that code would stick around taking up memory? What if I had this seriously large web application that starts and stops many widgets every time the user browse different areas (think the yahoo portal as a whole in one page that never refreshes)? How much memory and processing power would be necessary for this app not to crash due to all objects left behind by the modules? |
We will no longer be using the Todo application as a demo as we've landed a new version of Aura in master which will (eventually) have a different app for the example. |
when the Todos is not empty, clicking "Start Todos" causes same data to be rendered .
version: Backbone Aura 0.8 Developer Preview
steps to repeat the problem:
The text was updated successfully, but these errors were encountered: