Open Widdershin opened 8 years ago
I have this keys driver in one of my projects:
function makeKeysDriver () {
const keydown$ = Observable.fromEvent(document, 'keydown');
const keyup$ = Observable.fromEvent(document, 'keyup');
function isKey (key) {
return (event) => {
return event.keyCode === key;
}
}
return function keysDriver () {
return {
isDown: (key) => {
return Observable.merge(
keydown$.filter(isKey(key)).map(_ => true),
keyup$.filter(isKey(key)).map(_ => false)
).startWith(false)
}
}
}
}
Note the startWith(false)
. cycle-restart subscribes to this driver, but before the application has subscribed, so the initial false
value never makes it to the app. As such, I have to press all the keys I've subscribed to before a combineLatest will actually start up.
It's really a hot vs cold thing. It just so happens that the majority of drivers are hot so mostly there isn't an impact.
What are the implications?