1) replay(optional Coordination, optional CompositeSubscription) Turn a cold observable hot, send all earlier emitted values to any new subscriber, and allow connections to the source to be independent of subscriptions.
More...
1) replay(optional Coordination, optional CompositeSubscription) Turn a cold observable hot, send all earlier emitted values to any new subscriber, and allow connections to the source to be independent of subscriptions.
2) replay(Count, optional Coordination, optional CompositeSubscription) Turn a cold observable hot, send at most count of earlier emitted values to any new subscriber, and allow connections to the source to be independent of subscriptions.
3) replay(Duration, optional Coordination, optional CompositeSubscription) Turn a cold observable hot, send values emitted within a specified time window to any new subscriber, and allow connections to the source to be independent of subscriptions.
4) replay(Count, Duration, optional Coordination, optional CompositeSubscription) Turn a cold observable hot, send at most count of values emitted within a specified time window to any new subscriber, and allow connections to the source to be independent of subscriptions.
- Template Parameters
-
Duration | the type of the time interval (optional). |
Count | the type of the maximum number of the most recent items sent to new observers (optional). |
Coordination | the type of the scheduler (optional). |
- Parameters
-
count | the maximum number of the most recent items sent to new observers (optional). |
d | the duration of the window in which the replayed items must be emitted |
cn | a scheduler all values are queued and delivered on (optional). |
cs | the subscription to control lifetime (optional). |
- Returns
- rxcpp::connectable_observable that shares a single subscription to the underlying observable that will replay all of its items and notifications to any future observer.
- Sample Code\n
values.subscribe(
[](long v){printf("[1] OnNext: %ld\n", v);},
[](){printf("[1] OnCompleted\n");});
values.connect();
[](long v){printf("[2] OnNext: %ld\n", v);},
[](){printf("[2] OnCompleted\n");});
});
[1] OnNext: 1
[1] OnNext: 2
[1] OnNext: 3
[2] OnNext: 1
[2] OnNext: 2
[2] OnNext: 3
[1] OnNext: 4
[2] OnNext: 4
[1] OnNext: 5
[2] OnNext: 5
[1] OnCompleted
[2] OnCompleted
- Sample Code\n
printf("[thread %s] Start task\n", get_pid().c_str());
auto worker = coordination.create_coordinator().get_worker();
values.subscribe(
[](long v){printf("[thread %s][1] OnNext: %ld\n", get_pid().c_str(), v);},
[](){printf("[thread %s][1] OnCompleted\n", get_pid().c_str());});
});
values.subscribe(
[](long v){printf("[thread %s][2] OnNext: %ld\n", get_pid().c_str(), v);},
[](){printf("[thread %s][2] OnCompleted\n", get_pid().c_str());});
});
values.connect();
});
values.as_blocking().subscribe();
printf("[thread %s] Finish task\n", get_pid().c_str());
[thread 3070107664] Start task
[thread 3015701568][1] OnNext: 1
[thread 3015701568][1] OnNext: 2
[thread 3015701568][1] OnNext: 3
[thread 3015701568][2] OnNext: 1
[thread 3015701568][2] OnNext: 2
[thread 3015701568][2] OnNext: 3
[thread 3015701568][1] OnNext: 4
[thread 3015701568][2] OnNext: 4
[thread 3015701568][1] OnNext: 5
[thread 3015701568][2] OnNext: 5
[thread 3015701568][1] OnCompleted
[thread 3015701568][2] OnCompleted
[thread 3070107664] Finish task
- Sample Code\n
values.subscribe(
[](long v){printf("[1] OnNext: %ld\n", v);},
[](){printf("[1] OnCompleted\n");});
values.connect();
[](long v){printf("[2] OnNext: %ld\n", v);},
[](){printf("[2] OnCompleted\n");});
});
[1] OnNext: 1
[1] OnNext: 2
[1] OnNext: 3
[2] OnNext: 2
[2] OnNext: 3
[1] OnNext: 4
[2] OnNext: 4
[1] OnNext: 5
[2] OnNext: 5
[1] OnCompleted
[2] OnCompleted
- Sample Code\n
printf("[thread %s] Start task\n", get_pid().c_str());
auto worker = coordination.create_coordinator().get_worker();
values.subscribe(
[](long v){printf("[thread %s][1] OnNext: %ld\n", get_pid().c_str(), v);},
[](){printf("[thread %s][1] OnCompleted\n", get_pid().c_str());});
});
values.subscribe(
[](long v){printf("[thread %s][2] OnNext: %ld\n", get_pid().c_str(), v);},
[](){printf("[thread %s][2] OnCompleted\n", get_pid().c_str());});
});
values.connect();
});
values.as_blocking().subscribe();
printf("[thread %s] Finish task\n", get_pid().c_str());
[thread 3070107664] Start task
[thread 3007308864][1] OnNext: 1
[thread 3007308864][1] OnNext: 2
[thread 3007308864][1] OnNext: 3
[thread 3007308864][2] OnNext: 2
[thread 3007308864][2] OnNext: 3
[thread 3007308864][1] OnNext: 4
[thread 3007308864][2] OnNext: 4
[thread 3007308864][1] OnNext: 5
[thread 3007308864][2] OnNext: 5
[thread 3007308864][1] OnCompleted
[thread 3007308864][2] OnCompleted
[thread 3070107664] Finish task
- Sample Code\n
replay(std::chrono::milliseconds(125));
values.subscribe(
[](long v){printf("[1] OnNext: %ld\n", v);},
[](){printf("[1] OnCompleted\n");});
values.connect();
[](long v){printf("[2] OnNext: %ld\n", v);},
[](){printf("[2] OnCompleted\n");});
});
[1] OnNext: 1
[1] OnNext: 2
[1] OnNext: 3
[1] OnNext: 4
[2] OnNext: 2
[2] OnNext: 3
[2] OnNext: 4
[1] OnNext: 5
[2] OnNext: 5
[1] OnCompleted
[2] OnCompleted
- Sample Code\n
printf("[thread %s] Start task\n", get_pid().c_str());
auto worker = coordination.create_coordinator().get_worker();
replay(std::chrono::milliseconds(125), coordination);
values.subscribe(
[](long v){printf("[thread %s][1] OnNext: %ld\n", get_pid().c_str(), v);},
[](){printf("[thread %s][1] OnCompleted\n", get_pid().c_str());});
});
values.subscribe(
[](long v){printf("[thread %s][2] OnNext: %ld\n", get_pid().c_str(), v);},
[](){printf("[thread %s][2] OnCompleted\n", get_pid().c_str());});
});
values.connect();
});
values.as_blocking().subscribe();
printf("[thread %s] Finish task\n", get_pid().c_str());
[thread 3070107664] Start task
[thread 2996827200][1] OnNext: 1
[thread 2996827200][1] OnNext: 2
[thread 2996827200][1] OnNext: 3
[thread 2996827200][1] OnNext: 4
[thread 2996827200][2] OnNext: 2
[thread 2996827200][2] OnNext: 3
[thread 2996827200][2] OnNext: 4
[thread 2996827200][1] OnNext: 5
[thread 2996827200][2] OnNext: 5
[thread 2996827200][1] OnCompleted
[thread 2996827200][2] OnCompleted
[thread 3070107664] Finish task
- Sample Code\n
replay(2, std::chrono::milliseconds(125));
values.subscribe(
[](long v){printf("[1] OnNext: %ld\n", v);},
[](){printf("[1] OnCompleted\n");});
values.connect();
[](long v){printf("[2] OnNext: %ld\n", v);},
[](){printf("[2] OnCompleted\n");});
});
[1] OnNext: 1
[1] OnNext: 2
[1] OnNext: 3
[1] OnNext: 4
[2] OnNext: 3
[2] OnNext: 4
[1] OnNext: 5
[2] OnNext: 5
[1] OnCompleted
[2] OnCompleted
- Sample Code\n
printf("[thread %s] Start task\n", get_pid().c_str());
auto worker = coordination.create_coordinator().get_worker();
replay(2, std::chrono::milliseconds(125), coordination);
values.subscribe(
[](long v){printf("[thread %s][1] OnNext: %ld\n", get_pid().c_str(), v);},
[](){printf("[thread %s][1] OnCompleted\n", get_pid().c_str());});
});
values.subscribe(
[](long v){printf("[thread %s][2] OnNext: %ld\n", get_pid().c_str(), v);},
[](){printf("[thread %s][2] OnCompleted\n", get_pid().c_str());});
});
values.connect();
});
values.as_blocking().subscribe();
printf("[thread %s] Finish task\n", get_pid().c_str());
[thread 3070107664] Start task
[thread 2986341440][1] OnNext: 1
[thread 2986341440][1] OnNext: 2
[thread 2986341440][1] OnNext: 3
[thread 2986341440][1] OnNext: 4
[thread 2986341440][2] OnNext: 3
[thread 2986341440][2] OnNext: 4
[thread 2986341440][1] OnNext: 5
[thread 2986341440][2] OnNext: 5
[thread 2986341440][1] OnCompleted
[thread 2986341440][2] OnCompleted
[thread 3070107664] Finish task