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

Commit

Permalink
Closing Issue #947
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpodwysocki committed Oct 13, 2015
1 parent a1f10de commit f5dc9b0
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions doc/api/core/operators/publishvalue.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
### `Rx.Observable.prototype.publishValue([selector])`
### `Rx.Observable.prototype.publishValue([selector], initialValue)`
[Ⓢ](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/linq/observable/publishvalue.js "View in source")

Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence and starts with initialValue.

This operator is a specialization of `multicast` using a `Rx.BehaviorSubject`.

#### Arguments
1. `[selector]` *(`Function`)*: Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will immediately receive the initial value, followed by all notifications of the source from the time of the subscription on.
1. `[selector]`: `Function` - Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will immediately receive the initial value, followed by all notifications of the source from the time of the subscription on.
2. `initialValue`: `Any` - Initial value received by observers upon subscription.

#### Returns
*(ConnectableObservable)*: An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
`ConnectableObservable` - An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function and initial value.

#### Example
```js
var interval = Rx.Observable.interval(1000);

var source = interval
.take(2)
.doAction(function (x) {
console.log('Side effect');
});
.take(2)
.tap(function (x) {
console.log('Side effect');
});

var published = source.publishValue(42);

Expand All @@ -29,16 +30,16 @@ published.subscribe(createObserver('SourceB'));
var connection = published.connect();

function createObserver(tag) {
return Rx.Observer.create(
function (x) {
console.log('Next: ' + tag + x);
},
function (err) {
console.log('Error: ' + err);
},
function () {
console.log('Completed');
});
return Rx.Observer.create(
function (x) {
console.log('Next: ' + tag + x);
},
function (err) {
console.log('Error: ' + err);
},
function () {
console.log('Completed');
});
}

// => Next: SourceA42
Expand Down

0 comments on commit f5dc9b0

Please sign in to comment.