-
Notifications
You must be signed in to change notification settings - Fork 8
repeat
richardszalay edited this page May 20, 2011
·
8 revisions
Repeats a source sequence by resubscribing to it when it completes.
function repeat(repeatCount : uint = 0) : IObservable.<T>
Where repeatCount is the number of times to repeat (after the initial subscription), or 0 to repeat indefinitely.
When the source sequence completes, it will be resubscribed to.
If the source sequence errors, the sequence will error and the source sequence will not be resubscribed to.
The returned sequence completes when the source sequence has been re-subscribed to repeatCount number of times and completed. If repeatCount is 0, the returned sequence never completes.
The returned sequence errors if the source sequence errors.
xs ──o─────o─────o────/
│ │ │ └──o─────o─────o────/
│ │ │ │ │ │ │
ys ──o─────o─────o───────o─────o─────o────/
xs ──o─────o─────x
│ │ │
│ │ │
ys ──o─────o─────x
IObservable.<T>
Observable.range(1, 2).repeat(2)
.subscribe(
function(x : int) : void { trace(x); },
function():void { trace("Completed"); }
);
// Trace output is:
// 1
// 2
// 1
// 2
// 1
// 2
// Completed