ericvicenti/navigation-rfc

AnimationStackView onNavigation should return a promise for animation completion

Open

#9 aperta il 6 gen 2016

Vedi su GitHub
 (4 commenti) (0 reazioni) (0 assegnatari) (44 fork)github user discovery
help wanted

Metriche repository

Star
 (440 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

onNavigation() could return a promise that would allow to (optionally) track the completion of the navigation action.

For instance, if a button do a navigation push, you might want to make it display differently and disable it until the navigation is completed. I don't think it is the responsability to the button to "check if navigation is happening and disable it itself" but if the button onPress methods allow a function that (potentially) returns a promise, we could just do: <Button onPress={() => onNavigation(new Navigation.Action.Push('route'))} />

It's great to have a fine level of control over navigation action: on a single navigation action, user could know when the navigation has successfully moved to next screen or if it was aborted (by making the promise failing). Also the fact it's a promise make a great API to the user I think, because people might just ignore this detail and don't use it, but when you need it you can do a then() on the result.

(for context, I asked the same question on the old navigation api: https://github.com/facebook/react-native/issues/4824 )

Guida contributor