Repeat this observable for the given number of times or infinitely.
- Template Parameters
-
Count | the type of the counter (optional). |
- Parameters
-
t | The number of times the source observable items are repeated (optional). If not specified, infinitely repeats the source observable. Specifying 0 returns an empty sequence immediately |
- Returns
- An observable that repeats the sequence of items emitted by the source observable for t times.
- Sample Code
values.
[](int v){printf("OnNext: %d\n", v);},
[](){printf("OnCompleted\n");});
OnNext: 1
OnNext: 2
OnNext: 1
OnNext: 2
OnNext: 1
OnNext: 2
OnCompleted
If the source observable calls on_error, repeat stops: values.
[](int v){printf("OnNext: %d\n", v);},
[](std::exception_ptr ep){
try {std::rethrow_exception(ep);}
catch (const std::exception& ex) {
printf("OnError: %s\n", ex.what());
}
},
[](){printf("OnCompleted\n");});
OnNext: 1
OnNext: 2
OnError: Error
from source