Hi Tetsuro. Thanks for this library.
What is the preferred way to use the rxqt::run_loop in a larger codebase with a lot of classes?
As all qt gui related methods have to be run in the main (gui) thread, in all such cases, I need to add .observe_on(main_thread) before each .subscribe(...). I saw your example https://github.com/tetsurom/rxqt/blob/master/sample/thread/main.cpp, but when the code is spread among multiple source files, these options come to my mind:
- Encapsulate the
rxqt::run_loop in a singleton and initialize it after QApplication
- Create the
rxqt::run_loop after QApplication, and then put just the result of rxqt_run_loop.observe_on_run_loop() into a singleton.
- Before each place where I'd like to use
.observe_on(main_thread), I'd put
rxqt::run_loop rxqt_run_loop;
auto main_thread = rxqt_run_loop.observe_on_run_loop();
Are these approaches equivalent in functionality? The 2. option would lead to the least code bloat. What would you prefer?
Thanks for any hints.
Michal
Hi Tetsuro. Thanks for this library.
What is the preferred way to use the
rxqt::run_loopin a larger codebase with a lot of classes?As all qt gui related methods have to be run in the main (gui) thread, in all such cases, I need to add
.observe_on(main_thread)before each.subscribe(...). I saw your example https://github.com/tetsurom/rxqt/blob/master/sample/thread/main.cpp, but when the code is spread among multiple source files, these options come to my mind:rxqt::run_loopin a singleton and initialize it afterQApplicationrxqt::run_loopafterQApplication, and then put just the result ofrxqt_run_loop.observe_on_run_loop()into a singleton..observe_on(main_thread), I'd putAre these approaches equivalent in functionality? The
2.option would lead to the least code bloat. What would you prefer?Thanks for any hints.
Michal