Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions documentation/operators/amb.html
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,50 @@ <h4>Sample Code</h4>
</p>
{% endlang_operator %}

{% lang_operator RxPHP race %}
<figure class="variant">
<figcaption>
<p>
RxPHP implements this operator as <code>race</code>.
</p>
<p>
Propagates the observable sequence that reacts first. Also known as 'amb'.
</p>
<h4>Sample Code</h4>
<div class="code php">
<pre>
//from https://github.com/ReactiveX/RxPHP/blob/master/demo/race/race.php

$loop = \React\EventLoop\Factory::create();
$scheduler = new \Rx\Scheduler\EventLoopScheduler($loop);

$source = Rx\Observable::race(
[
Rx\Observable::timer(500)->map(function () {
return 'foo';
}),
Rx\Observable::timer(200)->map(function () {
return 'bar';
})
]
);

$source->subscribe($stdoutObserver, $scheduler);

$loop->run();

</pre>
</div>
<div class="output">
<pre>
Next value: bar
Complete!
</pre>
</div>
</figcaption>
</figure>
{% endlang_operator %}

{% lang_operator RxPY amb %}
<p>
<span style="color:#ff0000">TBD</span>
Expand Down
30 changes: 30 additions & 0 deletions documentation/operators/average.html
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,36 @@ <h4>Sample Code</h4>
</p>
{% endlang_operator %}

{% lang_operator RxPHP average %}
<figure class="variant">
<figcaption>
<p>
RxPHP implements this operator as <code>average</code>.
</p>
<p>
Computes the average of an observable sequence of values.
</p>
<h4>Sample Code</h4>
<div class="code php">
<pre>
//from https://github.com/ReactiveX/RxPHP/blob/master/demo/average/average.php

$source = Rx\Observable::range(0, 9)->average();

$subscription = $source->subscribe($stdoutObserver);

</pre>
</div>
<div class="output">
<pre>
Next value: 4
Complete!
</pre>
</div>
</figcaption>
</figure>
{% endlang_operator %}

{% lang_operator RxPY average %}
<p>
<span style="color:#ff0000">TBD</span>
Expand Down
26 changes: 24 additions & 2 deletions documentation/operators/flatmap.html
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ <h4>See Also</h4>
</ul>
{% endlang_operator %}

{% lang_operator RxPHP flatMap selectMany flatMapLatest concatMap concatMapTo %}
{% lang_operator RxPHP flatMap flatMapTo selectMany flatMapLatest concatMap concatMapTo %}
<figure class="variant">
<figcaption>
<p>
Expand All @@ -594,7 +594,7 @@ <h4>Sample Code</h4>

$selectManyObservable = $observable->flatMap(function ($value) {
return Rx\Observable::range(1, $value);
}, $scheduler);
});

$disposable = $selectManyObservable->subscribe($stdoutObserver, $scheduler);

Expand All @@ -620,6 +620,28 @@ <h4>Sample Code</h4>
Next value: 4
Next value: 5
Complete!
</pre>
</div>
</figcaption>
</figure><figure class="variant">
<figcaption>
<p>
RxPHP also has an operator <code>flatMapTo</code>.
</p>
<p>
Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
</p>
<h4>Sample Code</h4>
<div class="code php">
<pre>
//from https://github.com/ReactiveX/RxPHP/blob/master/demo/concat/flatMapTo.php


</pre>
</div>
<div class="output">
<pre>

</pre>
</div>
</figcaption>
Expand Down
35 changes: 34 additions & 1 deletion documentation/operators/map.html
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ <h4>See Also</h4>
</p>
{% endlang_operator %}

{% lang_operator RxPHP map mapWithIndex mapTo select %}
{% lang_operator RxPHP map mapWithIndex mapTo select pluck %}
<figure class="variant">
<figcaption>
<p>
Expand Down Expand Up @@ -336,6 +336,39 @@ <h4>Sample Code</h4>
Alias for Map
</p>

</figcaption>
</figure><figure class="variant">
<figcaption>
<p>
RxPHP also has an operator <code>pluck</code>.
</p>
<p>
Returns an Observable containing the value of a specified array index (if array) or property (if object) from all elements in the Observable sequence. If a property can't be resolved the observable will error.
</p>
<h4>Sample Code</h4>
<div class="code php">
<pre>
//from https://github.com/ReactiveX/RxPHP/blob/master/demo/pluck/pluck.php

$source = Rx\Observable::fromArray([
(object)['value' => 0],
(object)['value' => 1],
(object)['value' => 2]
])
->pluck('value');

$subscription = $source->subscribe($stdoutObserver);

</pre>
</div>
<div class="output">
<pre>
Next value: 0
Next value: 1
Next value: 2
Complete!
</pre>
</div>
</figcaption>
</figure>
{% endlang_operator %}
Expand Down
60 changes: 60 additions & 0 deletions documentation/operators/min.html
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,66 @@ <h4>Sample Code</h4>
</p>
{% endlang_operator %}

{% lang_operator RxPHP min %}
<figure class="variant">
<figcaption>
<p>
RxPHP implements this operator as <code>min</code>.
</p>
<p>
Returns the minimum value in an observable sequence according to the specified comparer.
</p>
<h4>Sample Code</h4>
<div class="code php">
<pre>
//from https://github.com/ReactiveX/RxPHP/blob/master/demo/min/min.php

/* Without comparer */
$source = \Rx\Observable::fromArray([1, 3, 5, 7, 9, 2, 4, 6, 8])
->min();

$subscription = $source->subscribe($createStdoutObserver());

</pre>
</div>
<div class="output">
<pre>
Next value: 1
Complete!
</pre>
</div>

<div class="code php">
<pre>
//from https://github.com/ReactiveX/RxPHP/blob/master/demo/min/min-with-comparer.php

/* With a comparer */
$comparer = function ($x, $y) {
if ($x > $y) {
return 1;
} elseif ($x < $y) {
return -1;
}
return 0;
};

$source = \Rx\Observable::fromArray([1, 3, 5, 7, 9, 2, 4, 6, 8])
->min($comparer);

$subscription = $source->subscribe($createStdoutObserver());

</pre>
</div>
<div class="output">
<pre>
Next value: 1
Complete!
</pre>
</div>
</figcaption>
</figure>
{% endlang_operator %}

{% lang_operator RxPY min min_by %}
<p>
<span style="color:#ff0000">TBD</span>
Expand Down
49 changes: 48 additions & 1 deletion documentation/operators/repeat.html
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ <h4>Sample Code</h4>
</p>
{% endlang_operator %}

{% lang_operator RxPHP repeat %}
{% lang_operator RxPHP repeat repeatWhen %}
<figure class="variant">
<figcaption>
<p>
Expand Down Expand Up @@ -316,6 +316,53 @@ <h4>Sample Code</h4>
Next value: 1
Next value: 2
Next value: 3
Complete!
</pre>
</div>
</figcaption>
</figure><figure class="variant">
<figcaption>
<p>
RxPHP also has an operator <code>repeatWhen</code>.
</p>
<p>
Returns an Observable that emits the same values as the source Observable with the exception of an onCompleted. An onCompleted notification from the source will result in the emission of a count item to the Observable provided as an argument to the notificationHandler function. If that Observable calls onComplete or onError then repeatWhen will call onCompleted or onError on the child subscription. Otherwise, this Observable will resubscribe to the source observable.
</p>
<h4>Sample Code</h4>
<div class="code php">
<pre>
//from https://github.com/ReactiveX/RxPHP/blob/master/demo/repeat/repeatWhen.php

$loop = \React\EventLoop\Factory::create();
$scheduler = new \Rx\Scheduler\EventLoopScheduler($loop);

$source = Rx\Observable::just(42)
->repeatWhen(function (\Rx\Observable $notifications) {
return $notifications
->scan(function ($acc, $x) {
return $acc + $x;
}, 0)
->delay(1000)
->doOnNext(function () {
echo "1 second delay", PHP_EOL;
})
->takeWhile(function ($count) {
return $count < 2;
});
});

$subscription = $source->subscribe($createStdoutObserver(), $scheduler);

$loop->run();

</pre>
</div>
<div class="output">
<pre>
Next value: 42
1 second delay
Next value: 42
1 second delay
Complete!
</pre>
</div>
Expand Down
31 changes: 31 additions & 0 deletions documentation/operators/sum.html
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,37 @@ <h4>Sample Code</h4>
</p>
{% endlang_operator %}

{% lang_operator RxPHP sum %}
<figure class="variant">
<figcaption>
<p>
RxPHP implements this operator as <code>sum</code>.
</p>
<p>
Computes the sum of a sequence of values
</p>
<h4>Sample Code</h4>
<div class="code php">
<pre>
//from https://github.com/ReactiveX/RxPHP/blob/master/demo/sum/sum.php

$source = Rx\Observable::range(1, 10)
->sum();

$subscription = $source->subscribe($stdoutObserver);

</pre>
</div>
<div class="output">
<pre>
Next value: 55
Complete!
</pre>
</div>
</figcaption>
</figure>
{% endlang_operator %}

{% lang_operator RxPY sum %}
<p>
<span style="color:#ff0000">TBD</span>
Expand Down
33 changes: 33 additions & 0 deletions documentation/operators/takelast.html
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,39 @@ <h4>Sample Code</h4>
</p>
{% endlang_operator %}

{% lang_operator RxPHP takeLast %}
<figure class="variant">
<figcaption>
<p>
RxPHP implements this operator as <code>takeLast</code>.
</p>
<p>
Returns a specified number of contiguous elements from the end of an observable sequence.
</p>
<h4>Sample Code</h4>
<div class="code php">
<pre>
//from https://github.com/ReactiveX/RxPHP/blob/master/demo/take/takeLast.php

$source = \Rx\Observable::range(0, 5)
->takeLast(3);

$source->subscribe($stdoutObserver);

</pre>
</div>
<div class="output">
<pre>
Next value: 2
Next value: 3
Next value: 4
Complete!
</pre>
</div>
</figcaption>
</figure>
{% endlang_operator %}

{% lang_operator RxPY take_last take_last_buffer take_last_with_time %}
<p>
<span style="color:#ff0000">TBD</span>
Expand Down