Skip to content

Instantly share code, notes, and snippets.

@asharov
Created May 3, 2013 17:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asharov/5511991 to your computer and use it in GitHub Desktop.
Save asharov/5511991 to your computer and use it in GitHub Desktop.
Prepending stuff to an Rx stream
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);
}
@pyrtsa
Copy link

pyrtsa commented May 3, 2013

return stream.startWith(nilValue) simplifies it a bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment