jonataslaw / getx

Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with Get.
MIT License
10.44k stars 1.63k forks source link

Navigation on state change #1386

Closed geovin89 closed 3 years ago

geovin89 commented 3 years ago

I am looking for an example or 'how to' on navigating to a new screen/perform an action on an observable state change. Both Obx and GetBuilder expects a widget in return but what I want is more like a BlocListener in Bloc library. Is it not possible in GetX?

jonataslaw commented 3 years ago

https://github.com/jonataslaw/getx/blob/master/documentation/en_US/state_management.md#workers

geovin89 commented 3 years ago

Thanks a lot for responding. This is quite interesting, even though I did read about workers I never really thought it can be used as a replacement for listeners.

Just to make sure I understood you correctly; The workers (initialized in the controller) can be used for navigation since Get.to() does not really rely on the context.

roipeker commented 3 years ago

Yes, just make sure you dispose/close your resources overriding GetxController.onClose().

Closing this issue as it's actually a question. Please use then other communication channels (Telegram/Discord) for further help.