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

Make it possible to create separate page instances #452

Closed matthewp closed 6 years ago

matthewp commented 6 years ago

It will be easier to solve problems like https://github.com/visionmedia/page.js/issues/222 once we do this. I was kind of waiting until 2.0 so we could use Object.setPrototypeOf and such to make the page() function inherit the page instances stuff, but now I wonder if it's too important to wait on that and if we should just do it a less fancy way.

matthewp commented 6 years ago

API I am thinking of is:

var newPage = page.create(options);

// You can also pass options this way
newPage.configure(options);

newPage('/', function(){

});

newPage.redirect('/foo', '/bar');

newPage.start();
matthewp commented 6 years ago

Oops, already have https://github.com/visionmedia/page.js/issues/13