Skip to content
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

redo API #6

Open
yoshuawuyts opened this issue Jun 28, 2017 · 4 comments
Open

redo API #6

yoshuawuyts opened this issue Jun 28, 2017 · 4 comments

Comments

@yoshuawuyts
Copy link
Member

yoshuawuyts commented Jun 28, 2017

var nanorouter = require('nanorouter')

var router = nanorouter()
router.route('default', function (params) {
})

router.route('/foo/:bar', function (params) {
})

router.match(window.location)

Base it on prototypes - and that's it I think ✨

@toddself
Copy link

why route instead of on? (I like on since it's sort of like an event emitter -- we're going to trigger this function when this event happens. Its just that the event is the browser's URL being changed)

@yoshuawuyts
Copy link
Member Author

yoshuawuyts commented Jun 28, 2017 via email

@timwis
Copy link
Member

timwis commented Jun 28, 2017

Also on might imply multiple handlers would be called if you defined them, and I assume that's not the case (though maybe?).

The use of default as a route like that feels smelly to me, but not sure what to propose instead and you may have already thought about this. What if the way you defined the default route was to define a .route('*', ...) route at the very end? In theory that would work with no code changes, and is thus less API to memorise. Right? Or would it be called in addition to matched handlers..

@yoshuawuyts
Copy link
Member Author

yoshuawuyts commented Jun 29, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants