int main()
{
// rxqt loop
rxqt::run_loop rxqt_run_loop;
// main线程
rxcpp::observe_on_one_worker main_thread = rxqt_run_loop.observe_on_run_loop();
// 初始化UI线程
ThreadTool::getInstance()->main_thread = main_thread;
return 0;
}
rxcpp::observable<>::create<int>([](rxcpp::subscriber<int> subscriber)
{
for (int i = 0; i < 3; i++)
{
std::cout << " sub : " << std::this_thread::get_id() << std::endl;
subscriber.on_next(i);
QThread::sleep(1);
}
})
.subscribe_on(rxcpp::observe_on_event_loop())
.observe_on(ThreadTool::getInstance()->main_thread)
.subscribe(
[this, username, password, savePassword, autoLogin](int i)
{
std::cout << " obs : " << i << " " << std::this_thread::get_id() << std::endl;
if (i == 2)
{
}
});