How to observe on main/ui thread?

Dec 21, 2014 at 10:02 AM
Hi,

I'm trying to have a worker thread publish to an observable observing on the ui thread. I see in the MFC time flies sample that you would do it like so:
auto mainFormScheduler = std::make_shared<rxcpp::win32::WindowScheduler>();
.observe_on(mainFormScheduler)
Seems that v2 changed. I'm confused on to what scheduler I should choose, I tried capturing rxcpp::rxsc::make_current_thread() while in the main thread. That seems like a sentinel value for using the thread that is publishing values.

rxcpp::observe_on_event_loop() looks promising, but it observes on a worker thread. This is what I have:
    _sbj_auto_complete_results.get_observable()
        .observe_on(rx::observe_on_event_loop())
        .subscribe([this](std::tuple<wstring, cell_list> tu)
    {
        _set_auto_complete_text(std::get<0>(tu), std::get<1>(tu));
    });

    _sbj_auto_complete_changes.get_observable()
        .observe_on(rx::observe_on_new_thread())
        .subscribe([this](wstring s)
    {
        ...
        _sbj_auto_complete_results.get_subscriber().on_next(
            std::make_tuple(s, cl));
    });
Any help appreciated. Thank you.
Coordinator
Dec 21, 2014 at 7:11 PM
Thanks for the question!

Yes, v2 has not ported the win32 and winrt adapters from v1 yet.

It should not be too hard to port the WindowScheduler. Contributions are welcome! Otherwise, I do not know when that work would be picked up.
Coordinator
Dec 21, 2014 at 7:14 PM
For tracking, I opened an issue on github (github is the source-of-truth now)
https://github.com/Reactive-Extensions/RxCpp/issues/52