Hello compose guys,
With the navigation compose version 2.8.0-alpha08 i find out that i can popBackStack to a destination which defined as data object
and pass result value via any field defined in data object. I didn't see any mentions about that so i wonder if that usage is correct or not ?
Copy code
@Serializable
data object TodoListDestination: Destination {
var returnValue: String? = null
}
val controller = rememberNavController()
controller.popBackStack(
route = TodoListDestination.apply { returnValue = "Result" },
inclusive = false,
)
i
Ian Lake
05/18/2024, 2:32 AM
A
var
within an object is just a global variable, you're not "returning a result" at all, just building a dependency on global variable that isn't even composition aware (it just happens to work because the other screen isn't being composed when you set the variable - it wouldn't work at all if it was a Dialog destination, for instance, unless something else were to cause a chance recomposition)
a
Ahmet Özcan
05/19/2024, 5:37 PM
Thank you Ian at some point i forget that object is just a static i don't know what makes me think like that 😄