ReactivePlusPlus
ReactiveX implementation for C++20
|
Main RPP wrapper over disposables. More...
#include <disposable_wrapper.hpp>
Public Member Functions | |
bool | operator== (const disposable_wrapper_impl &) const =default |
template<rpp::constraint::is_nothrow_invocable Fn> requires std::derived_from<TDisposable, interface_composite_disposable> | |
disposable_wrapper | add (Fn &&invocable) |
void | add (disposable_wrapper other) const |
void | remove (const disposable_wrapper &other) const |
void | clear () const |
std::shared_ptr< TDisposable > | lock () const noexcept |
disposable_wrapper_impl | as_weak () const |
template<constraint::decayed_type TTarget> requires rpp::constraint::static_pointer_convertible_to<TDisposable, TTarget> | |
operator disposable_wrapper_impl< TTarget > () const | |
Public Member Functions inherited from rpp::details::disposable_wrapper_base | |
bool | operator== (const disposable_wrapper_base &other) const |
bool | is_disposed () const noexcept |
void | dispose () const noexcept |
Static Public Member Functions | |
template<std::derived_from< TDisposable > TTarget = TDefaultMake, typename... TArgs> requires (std::constructible_from<TTarget, TArgs && ...>) | |
static disposable_wrapper_impl | make (TArgs &&... args) |
Main way to create disposable_wrapper. Passed TTarget type can be any type derived from TDisposable . | |
static disposable_wrapper_impl | empty () |
Creates disposable_wrapper which behaves like disposed disposable. | |
Friends | |
template<rpp::constraint::decayed_type TTarget> | |
class | details::enable_wrapper_from_this |
Additional Inherited Members | |
Protected Member Functions inherited from rpp::details::disposable_wrapper_base | |
disposable_wrapper_base (std::shared_ptr< interface_disposable > &&disposable) | |
disposable_wrapper_base (std::weak_ptr< interface_disposable > &&disposable) | |
std::pair< std::shared_ptr< interface_disposable >, bool > | get () const noexcept |
Main RPP wrapper over disposables.
This wrapper invented to provide safe and easy-to-use access to disposables. It has next core points:
dispose()
during it's destruction (during destruction of last disposable_wrapper owning it)dispose()
, is_disposed()
and add()
/remove()
/clear()
(for interface_composite_disposable
).To construct wrapper you have to use make
method:
To achieve desired performance RPP is avoiding to returning disposable by default. So, it is why subscribe
method is not returning anything by default. If you want to attach disposable to observer you can use overloading method accepting disposable as first argument like this:
or use subscribe_with_disposable
method instead
|
inlinestaticnodiscard |
Main way to create disposable_wrapper. Passed TTarget
type can be any type derived from TDisposable
.