Skip to content

Instantly share code, notes, and snippets.

@scottcorgan
Created February 18, 2016 16:20
Show Gist options
  • Save scottcorgan/7bbc83203d978cb35f8f to your computer and use it in GitHub Desktop.
Save scottcorgan/7bbc83203d978cb35f8f to your computer and use it in GitHub Desktop.
function main (sources) {
let {DOM} = sources
function preventDefault (e) {
e.preventDefault()
return e
}
let routeTo$ = DOM.select('a').events('click')
.filter(e => e.target.getAttribute('href') && !e.target.getAttribute('target'))
.map(preventDefault)
.map(e => e.target.getAttribute('href'))
return {
router: routeTo$
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment