Last active
December 12, 2015 01:09
-
-
Save cwharris/4689355 to your computer and use it in GitHub Desktop.
Rx.Observable.combineTemplate takes an object with key/value pairs of observables, and returns an observable which yields objects with key/value pairs of values which have been provided internally using Rx.Observable.combineLatest.
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
Rx.Observable.combineTemplate = function(sources) { | |
var keys = []; | |
var values = []; | |
for (var key in sources) { | |
keys.push(key); | |
values.push(sources[key]); | |
} | |
return Rx.Observable.combineLatest(values, function() { | |
var template = {}; | |
for (var i = 0, len = keys.length; i < len; i++) { | |
template[keys[i]] = arguments[i]; | |
} | |
return template; | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment