Fix NavigationEvent types (#3384)

* Fix SimpleTabs types

dca37627a2 broke the types, but it wasn't noticed because Flow wasn't in the CI. This fixes the types; separate PR coming to add Flow to the CI.

* Refine type of NavigationEventListener callback

Instead of typing the callback as `Function`, we're now using the precise type provided by @ericvicenti

* NavigationEventListener -> NavigationEventSubscription
This commit is contained in:
Ashoat Tevosyan
2018-01-30 18:49:47 -05:00
committed by Eric Vicenti
parent d1d81d7033
commit 0d3d83bd90
3 changed files with 59 additions and 18 deletions

View File

@@ -414,7 +414,23 @@ export type NavigationProp<S> = {
dispatch: NavigationDispatch,
};
export type EventListener = {
export type EventType =
| 'willFocus'
| 'didFocus'
| 'willBlur'
| 'didBlur'
| 'action';
export type NavigationEventPayload = {
type: EventType,
action: NavigationAction,
state: NavigationState,
lastState: NavigationState,
};
export type NavigationEventCallback = (payload: NavigationEventPayload) => void;
export type NavigationEventSubscription = {
remove: () => void,
};
@@ -428,7 +444,10 @@ export type NavigationScreenProp<+S> = {
action?: NavigationNavigateAction
) => boolean,
setParams: (newParams: NavigationParams) => boolean,
addListener: (eventName: string, callback: Function) => EventListener,
addListener: (
eventName: string,
callback: NavigationEventCallback
) => NavigationEventSubscription,
};
export type NavigationNavigatorProps<O: {}, S: {}> = {