AmpersandJS / ampersand-router

Clientside router with fallbacks for browsers that don't support pushState. Mostly lifted from Backbone.js.
MIT License
70 stars 16 forks source link

Basic readme example not cleaning up stuff? #39

Closed alessioalex closed 9 years ago

alessioalex commented 9 years ago
    home: function () {
        this.trigger('newPage', new HomePage());
    },

This means that whenever you go to the homepage it will create a new instance of HomePage and probably bind some events. That code suggests that the events don't get cleaned up.

I think it's better to update the example to either store the last view and then cleanup or to use the ampersand-view-switcher.

lukekarrys commented 9 years ago

I think incorporating ampersand-view-switcher code into the readme example is a little outside the scope of the router's documentation, since it would also require us to show the code for a view to instantiate the view-switcher.

I do think the example should be updated. I'm thinking we should put a note in there, about using app.trigger like we do in the ampersand cli generated app's router and main view.

I'll work on getting a PR with the updated example.