Created
May 3, 2013 17:55
-
-
Save asharov/5511991 to your computer and use it in GitHub Desktop.
Prepending stuff to an Rx stream
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function prependNilObject(stream) { | |
var nilValue = {}; | |
for (var i = 1; i < arguments.length; ++i) { | |
nilValue[arguments[i]] = null; | |
} | |
var nilStream = Rx.Observable.returnValue(nilValue); | |
return nilStream.concat(stream); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
return stream.startWith(nilValue)
simplifies it a bit.