-
- All Implemented Interfaces:
-
com.ramcosta.composedestinations.result.OpenResultRecipient,com.ramcosta.composedestinations.result.ResultRecipient
public final class EmptyResultRecipient<D extends TypedDestinationSpec<?>, R extends Object> implements ResultRecipient<D, R>
Empty implementation of ResultRecipient to use in previews and possibly testing.
-
-
Constructor Summary
Constructors Constructor Description EmptyResultRecipient()
-
Method Summary
Modifier and Type Method Description UnitonNavResult(Function1<NavResult<R>, Unit> listener)Install a listener that will be called when the D destination finishes. UnitonNavResult(OpenResultRecipient.DeliverResultOn deliverResultOn, Function1<NavResult<R>, Unit> listener)Same as onNavResult but allows you to control when the result will be delivered. -
-
Method Detail
-
onNavResult
Unit onNavResult(Function1<NavResult<R>, Unit> listener)
Install a listener that will be called when the D destination finishes. NavResult will either contain a specific result R for NavResult.Value or it will be NavResult.Canceled if D finishes without setting any result.
Implementation makes sure to only do something the first time it is called, so, no need to worry about recomposition.
listener will not be called from a Compose scope, it should be treated as a normal button click listener, you can navigate or call a method on a view model, for example.
-
onNavResult
Unit onNavResult(OpenResultRecipient.DeliverResultOn deliverResultOn, Function1<NavResult<R>, Unit> listener)
Same as onNavResult but allows you to control when the result will be delivered. By default, with onNavResult it is delivered on first opportunity between ON_RESUME and ON_START, because in some scenarios, ON_RESUME or ON_START are not triggered.
However, if in your specific use case, you find that one works better than the other, you can control it by passing specifically DeliverResultOn.START or DeliverResultOn.RESUME
-
-
-
-