Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
cycle-hashchange-driver
Advanced tools
A Cycle.js driver for navigation.
makePushStateDriver ()
Returns a navigation driver that calls history.pushState
on the input paths and outputs paths sent to pushState
as well as received with popstate
events, starting with the current path.
makeHashChangeDriver ()
Returns a navigation driver that sets location.hash
to the input hashes and outputs hashes received with hashchange
events, starting with the current hash.
makeNavigationDriver ()
Returns the pushState driver if history.pushState
is available, otherwise returns the hashchange Driver.
Only available via git for now. I will publish this module on npm once I have added tests.
Basics:
import Cycle from '@cycle/core'
import { makeNavigationDriver } from 'cycle-navigation-driver'
function main (responses) {
// ...
}
const drivers = {
Navigation: makeNavigationDriver()
}
Cycle.run(main, drivers)
Simple use case:
function main(responses) {
let localLinkClick$ = DOM.select('a').events('click')
.filter(e => e.currentTarget.host === location.host)
let navigate$ = localLinkClick$
.map(e => e.currentTarget.href)
let vtree$ = responses.Navigation
.map(url => {
switch(url) {
case '/':
renderHome()
break
case '/user':
renderUser()
break
default:
render404()
break
}
})
return {
DOM: vtree$,
Navigation: navigate$,
preventDefault: localLinkClick$
};
}
Routing use case:
import switchPath from 'switch-path'
import routes from './routes'
function resolve (path) {
return switchPath(path, routes)
}
function main(responses) {
let localLinkClick$ = DOM.select('a').events('click')
.filter(e => e.currentTarget.host === location.host)
let navigate$ = localLinkClick$
.map(e => e.currentTarget.href)
let vtree$ = responses.Navigation
.map(resolve)
.map(({ value }) => value)
return {
DOM: vtree$,
Navigation: navigate$,
preventDefault: localLinkClick$
};
}
FAQs
A Cycle.js driver for the hashchange event
The npm package cycle-hashchange-driver receives a total of 8 weekly downloads. As such, cycle-hashchange-driver popularity was classified as not popular.
We found that cycle-hashchange-driver demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.