Skip to content

Commit

Permalink
Updating documentation for object combine
Browse files Browse the repository at this point in the history
  • Loading branch information
J. Holmes committed Dec 28, 2016
1 parent cea5472 commit cc1549e
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion docs-src/descriptions/multiple-sources.jade
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,40 @@ pre(title='events in time').
result: ------•--•-•X
9 12 14

div

p.
Also, #[b combine] supports passing objects as both #[b obss] #[i and] #[b passiveObss].
The #[b combinator] function will then be called with a single argument, a new object with
the latest value from each observable. If no #[b combinator] is provided, it emits
the object containing latest values.

pre.javascript(title='example')
:escapehtml
var aStream = Kefir.sequentially(100, [1, 3]);
var bStream = Kefir.sequentially(100, [2, 4]).delay(40);

var result = Kefir.combine({ a: aStream, b: bStream });
result.log();

pre(title='console output')
:escapehtml
> [combine] <value> { a: 1, b: 2 }
> [combine] <value> { a: 3, b: 2 }
> [combine] <value> { a: 3, b: 4 }
> [combine] <end>

pre(title='events in time').
a: ----1----3X
b: ------2----4X

result: ------•--•-•X

p.
#[img(data-emoji="point_up")] If there are duplicate keys in both #[b obss]
#[i and] #[b passiveObss], only the latest values from #[b obss] will appear
in the combined object for the duplicated keys.

p.
The result stream emits a value only when it has at least one value from each of source observables.
Ends when all the active source observables (#[b obss] array) end.
Expand All @@ -70,7 +104,6 @@ p.




+descr-method('zip', 'zip', 'Kefir.zip(sources, [combinator])', 'obs.zip(otherObs, [combinator])').
Creates a stream with values from #[b sources]
lined up with each other. For example if you have two sources with values
Expand Down

0 comments on commit cc1549e

Please sign in to comment.