Created
July 2, 2016 13:38
-
-
Save ntilwalli/6d6f75027e02caa7f540e81646ba07f3 to your computer and use it in GitHub Desktop.
Equivalent to rx-combine-latest-obj for xstream
This file contains hidden or 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
import xs from 'xstream' | |
export default function combineObj(obj) { | |
var sources = []; | |
var keys = []; | |
for (var key in obj) { | |
if (obj.hasOwnProperty(key)) { | |
keys.push(key.replace(/\$$/, '')); | |
sources.push(obj[key]); | |
} | |
} | |
return xs.combine(...sources).map(function () { | |
var args = arguments[0] | |
var argsLength = args.length; | |
var combination = {}; | |
for (var i = argsLength - 1; i >= 0; i--) { | |
combination[keys[i]] = args[i]; | |
} | |
return combination; | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment