Hi, I am using resultRecipient() which works in th...
# compose-destinations
m
Hi, I am using resultRecipient() which works in the composable destination. However, I have a usecase where I want to open a dialog from the activity and collect that result. I can get the navigator to navigate to that dialog and the dialog will have the defined resultBackNavigator, but I am not sure how to get resultRecipient in the activity so that I could listen to the result (the activity uses composables, but that is not defined as a DestinationSpec that would have access to the extension function resultRecipient). Basically same as the last comment question in https://github.com/raamcosta/compose-destinations/issues/195
r
For sure you could launch a screen destination with given dialog style and then you could probably fetch the result from ResultBackNavigator using recipient You can also launch a classic dialog fragment and pass a high order function to get a callback
m
I want to avoid a classic dialog calling from activity, because I have the dialog defined in the navigation graph where it automatically tracks some navigation analytics, and I would like to reuse that dialogComposable for other destinations, it would be better if activity could also listen to those results (it can navigate to a destination). @Rafael Costa any thoughts on what I am missing? The dialog is needed on the main activity, because I trigger it by listening to onResume call for the whole app.
r
This feature is meant to work only in between two composable destinations. What you could do is implement ResultBackNavigator to pass to your dialog when coming from the activity, and use some other way to let the activity know about the result in that implementation.
It’s safe to pass the activity reference to that implementation of ResultBackNavigator, so you can probably even just call some method on the activity. I’m not sure, I’d have to try it 🙂
m
Thank you! I will look into it. I will also look into moving the logic to navigate to dialog only to destinations where it might be slightly duplicated, but would work in the original result way and allows those destinations to react differently.