Skip to content
This repository has been archived by the owner on Apr 20, 2018. It is now read-only.

Commit

Permalink
Updating forkJoin docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpodwysocki committed Oct 13, 2015
1 parent 5be5683 commit 031e887
Show file tree
Hide file tree
Showing 25 changed files with 1,723 additions and 1,325 deletions.
461 changes: 256 additions & 205 deletions dist/rx.all.compat.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/rx.all.compat.map

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions dist/rx.all.compat.min.js

Large diffs are not rendered by default.

459 changes: 255 additions & 204 deletions dist/rx.all.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/rx.all.map

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions dist/rx.all.min.js

Large diffs are not rendered by default.

466 changes: 258 additions & 208 deletions dist/rx.experimental.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/rx.experimental.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/rx.experimental.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 37 additions & 16 deletions doc/api/core/operators/forkjoin.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,58 @@
### `Rx.Observable.forkJoin(...args)`
### `Rx.Observable.forkJoin(...args, [resultSelector])`
[Ⓢ](https://github.com/Reactive-Extensions/RxJS/blob/master/tests/observable/forkjoin.js "View in source")

Runs all observable sequences in parallel and collect their last elements.

#### Arguments
1. `args` *(Arguments | Array)*: An array or arguments of Observable sequences or Promises to collect the last elements for.
2. `resultSelector`: `Function` - The result selector from all the values produced. If not specified, `forkJoin` will return the results as an array.

#### Returns
*(`Observable`)*: An observable sequence with an array collecting the last elements of all the input sequences.
*(`Observable`)*: An observable sequence with an array collecting the last elements of all the input sequences or the result of the result selector if specified.

#### Example
```js
/* Using observables and Promises */
/* Without a selector */
var source = Rx.Observable.forkJoin(
Rx.Observable.return(42),
Rx.Observable.range(0, 10),
Rx.Observable.from([1,2,3]),
RSVP.Promise.resolve(56)
Rx.Observable.return(42),
Rx.Observable.range(0, 10),
Rx.Observable.from([1,2,3]),
RSVP.Promise.resolve(56)
);

var subscription = source.subscribe(
function (x) {
console.log('Next: ' + x);
},
function (err) {
console.log('Error: ' + err);
},
function () {
console.log('Completed');
});
function (x) {
console.log('Next: %s', x);
},
function (err) {
console.log('Error: %s', err);
},
function () {
console.log('Completed');
});

// => Next: [42, 9, 3, 56]
// => Completed

var source = Rx.Observable.forkJoin(
Rx.Observable.just(42),
Rx.Observable.just(56),
function (x, y) { return x + y; }
);

var subscription = source.subscribe(
function (x) {
console.log('Next: %s', x);
},
function (err) {
console.log('Error: %s', err);
},
function () {
console.log('Completed');
});

// => Next: 98
// => Completed
```

### Location
Expand Down
60 changes: 38 additions & 22 deletions doc/api/core/operators/forkjoinproto.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,52 @@
### `Rx.Observable.prototype.forkJoin(second, resultSelector)`
### `Rx.Observable.prototype.forkJoin(...args, [resultSelector])`
[Ⓢ](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/linq/observable/forkjoinproto.js "View in source")

Runs two observable sequences in parallel and combines their last elements.
Runs all observable sequences in parallel and collect their last elements.

#### Arguments
1. `second` *(`Observable`)*: Second observable sequence.
2. `resultSelector` *(`Any`)*: The default value if no such element exists. If not specified, defaults to null.
1. `args`: `Arguments` | `Array` - An array or arguments of Observable sequences or Promises to collect the last elements for.
2. `resultSelector`: `Function` - The result selector from all the values produced. If not specified, `forkJoin` will return the results as an array.

#### Returns
*(`Observable`)*: An observable sequence that contains elements from the input sequence that satisfy the condition.
*(`Observable`)*: An observable sequence with an array collecting the last elements of all the input sequences or the result of the result selector if specified.

#### Example
```js
var source1 = Rx.Observable.return(42);
var source2 = Rx.Observable.range(0, 3);
// With a selector
var source = Rx.Observable.just(42).forkJoin(
Rx.Observable.range(0, 3),
function (s1, s2) { return s1 + s2; });

var source = source1.forkJoin(source2, function (s1, s2) {
return s1 + s2;
});
var subscription = source.subscribe(
function (x) {
console.log('Next: %s', x);
},
function (err) {
console.log('Error: %s', err);
},
function () {
console.log('Completed');
});

// => Next: 44
// => Completed

// Without a selector
var source = Rx.Observable.just(42).forkJoin(
Rx.Observable.range(0, 3));

var subscription = source.subscribe(
function (x) {
console.log('Next: ' + x);
},
function (err) {
console.log('Error: ' + err);
},
function () {
console.log('Completed');
});

// => Next: 45
function (x) {
console.log('Next: %s', x);
},
function (err) {
console.log('Error: %s', err);
},
function () {
console.log('Completed');
});

// => Next: [42, 2]
// => Completed
```

Expand All @@ -55,4 +71,4 @@ NuGet Packages:
- [`RxJS-Experimental`](http://www.nuget.org/packages/RxJS-Experimental)

Unit Tests:
- [`/tests/observable/forkjoinproto.js`](https://github.com/Reactive-Extensions/RxJS/blob/master/tests/observable/forkjoinproto.js)
- [`/tests/observable/forkjoin.js`](https://github.com/Reactive-Extensions/RxJS/blob/master/tests/observable/forkjoin.js)
Loading

0 comments on commit 031e887

Please sign in to comment.