visionmedia / page.js

Micro client-side router inspired by the Express router
http://visionmedia.github.com/page.js
7.67k stars 687 forks source link

Default global Page event bindings prevent other Page instances events from working correctly #508

Closed kaisermann closed 5 years ago

kaisermann commented 5 years ago

If you try to create a instance with the createPage method instead of using the global page instance, since the this.configure runs at the new Page() step AND at the page.start, you end up with two event handlers running at the same time.

Also, the options object passed onto createPage is currently not used

Edit:

My bad, the bindings are not duplicated. The problem is that the default globalPage bindings aren't working well with another instance of page, even if you don't use it.

The current workaround to this is to call globalPage.start() and then globalPage.stop() which removes the listeners.

Edit 2:

A simple globalPage.stop() won't work because it checks for this._running which is set only inside .start()