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
[](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();
[](long v){printf("[thread %s][1] OnNext: %ld\n", get_pid().c_str(), v);},
[](){printf("[thread %s][1] OnCompleted\n", get_pid().c_str());});
});
[](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();
});
printf("[thread %s] Finish task\n", get_pid().c_str());
[thread 139846724265792] Start task
[thread 139846467180288][1] OnNext: 1
[thread 139846467180288][1] OnNext: 2
[thread 139846467180288][1] OnNext: 3
[thread 139846467180288][2] OnNext: 1
[thread 139846467180288][2] OnNext: 2
[thread 139846467180288][2] OnNext: 3
[thread 139846467180288][1] OnNext: 4
[thread 139846467180288][2] OnNext: 4
[thread 139846467180288][1] OnNext: 5
[thread 139846467180288][2] OnNext: 5
[thread 139846467180288][1] OnCompleted
[thread 139846467180288][2] OnCompleted
[thread 139846724265792] Finish task
- Sample Code\n
[](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();
[](long v){printf("[thread %s][1] OnNext: %ld\n", get_pid().c_str(), v);},
[](){printf("[thread %s][1] OnCompleted\n", get_pid().c_str());});
});
[](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();
});
printf("[thread %s] Finish task\n", get_pid().c_str());
[thread 139846724265792] Start task
[thread 139846458787584][1] OnNext: 1
[thread 139846458787584][1] OnNext: 2
[thread 139846458787584][1] OnNext: 3
[thread 139846458787584][2] OnNext: 2
[thread 139846458787584][2] OnNext: 3
[thread 139846458787584][1] OnNext: 4
[thread 139846458787584][2] OnNext: 4
[thread 139846458787584][1] OnNext: 5
[thread 139846458787584][2] OnNext: 5
[thread 139846458787584][1] OnCompleted
[thread 139846458787584][2] OnCompleted
[thread 139846724265792] Finish task
- Sample Code\n
replay(std::chrono::milliseconds(125));
[](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);
[](long v){printf("[thread %s][1] OnNext: %ld\n", get_pid().c_str(), v);},
[](){printf("[thread %s][1] OnCompleted\n", get_pid().c_str());});
});
[](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();
});
printf("[thread %s] Finish task\n", get_pid().c_str());
[thread 139846724265792] Start task
[thread 139846450394880][1] OnNext: 1
[thread 139846450394880][1] OnNext: 2
[thread 139846450394880][1] OnNext: 3
[thread 139846450394880][1] OnNext: 4
[thread 139846450394880][2] OnNext: 2
[thread 139846450394880][2] OnNext: 3
[thread 139846450394880][2] OnNext: 4
[thread 139846450394880][1] OnNext: 5
[thread 139846450394880][2] OnNext: 5
[thread 139846450394880][1] OnCompleted
[thread 139846450394880][2] OnCompleted
[thread 139846724265792] Finish task
- Sample Code\n
replay(2, std::chrono::milliseconds(125));
[](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);
[](long v){printf("[thread %s][1] OnNext: %ld\n", get_pid().c_str(), v);},
[](){printf("[thread %s][1] OnCompleted\n", get_pid().c_str());});
});
[](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();
});
printf("[thread %s] Finish task\n", get_pid().c_str());
[thread 139846724265792] Start task
[thread 139846442002176][1] OnNext: 1
[thread 139846442002176][1] OnNext: 2
[thread 139846442002176][1] OnNext: 3
[thread 139846442002176][1] OnNext: 4
[thread 139846442002176][2] OnNext: 3
[thread 139846442002176][2] OnNext: 4
[thread 139846442002176][1] OnNext: 5
[thread 139846442002176][2] OnNext: 5
[thread 139846442002176][1] OnCompleted
[thread 139846442002176][2] OnCompleted
[thread 139846724265792] Finish task