diff options
Diffstat (limited to 'Rx/v2/src/rxcpp/sources/rx-create.hpp')
-rw-r--r-- | Rx/v2/src/rxcpp/sources/rx-create.hpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Rx/v2/src/rxcpp/sources/rx-create.hpp b/Rx/v2/src/rxcpp/sources/rx-create.hpp index ed27fea..95b9533 100644 --- a/Rx/v2/src/rxcpp/sources/rx-create.hpp +++ b/Rx/v2/src/rxcpp/sources/rx-create.hpp @@ -7,6 +7,41 @@ #include "../rx-includes.hpp" +/*! \file rx-create.hpp + + \brief Returns an observable that executes the specified function when a subscriber subscribes to it. + + \tparam T the type of the items that this observable emits + \tparam OnSubscribe the type of OnSubscribe handler function + + \param os OnSubscribe event handler + + \return Observable that executes the specified function when a Subscriber subscribes to it. + + \sample + \snippet create.cpp Create sample + \snippet output.txt Create sample + + \warning + It is good practice to check the observer's is_subscribed state from within the function you pass to create + so that your observable can stop emitting items or doing expensive calculations when there is no longer an interested observer. + + \badcode + \snippet create.cpp Create bad code + \snippet output.txt Create bad code + + \goodcode + \snippet create.cpp Create good code + \snippet output.txt Create good code + + \warning + It is good practice to use operators like observable::take to control lifetime rather than use the subscription explicitly. + + \goodcode + \snippet create.cpp Create great code + \snippet output.txt Create great code +*/ + namespace rxcpp { namespace sources { @@ -41,6 +76,8 @@ struct create : public source_base<T> } +/*! @copydoc rx-create.hpp + */ template<class T, class OnSubscribe> auto create(OnSubscribe os) -> observable<T, detail::create<T, OnSubscribe>> { |