發(fā)起方 XXX
通過使用ResultRecipient參數(shù)來實現(xiàn)注冊回調(diào)監(jiān)聽帮碰。
@Destination
@Composable
fun XXX(
navigator: DestinationsNavigator = EmptyDestinationsNavigator,
result: ResultRecipient<YYYDestination, String> = EmptyResultRecipient(),
) {
result.onNavResult {
EchoLog.log("resultRecipient", it)
when (it) {
is NavResult.Canceled -> {}
is NavResult.Value -> {
//----
}
}
}
}
返回方Y(jié)YY
通過ResultBackNavigator來實現(xiàn)數(shù)據(jù)回傳
@Destination
@Composable
fun YYY(
navigator: DestinationsNavigator = EmptyDestinationsNavigator,
resultBackNavigator: ResultBackNavigator<String> = EmptyResultBackNavigator()
) {
//在需要返回的地方
resultBackNavigator.navigateBack("ans")
}