Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ca51236

Browse files
Natimcknitt
authored andcommitted
Add the addListener binding. (#9)
1 parent 4224d8d commit ca51236

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

‎example/src/components/Search.re‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ module SearchHeader = {
2424

2525
module SearchList = {
2626
[@react.component]
27-
let make = (~navigation) => placeholder(~navigation, ~text="SearchList");
27+
let make = (~navigation) => {
28+
navigation.addListener(`didFocus, event => Js.log2("didFocus", event));
29+
placeholder(~navigation, ~text="SearchList");
30+
};
2831

2932
NavigationOptions.(
3033
make->setDynamicNavigationOptions(params =>

‎src/Navigation.re‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1+
open ReactNative;
12
type t;
23

4+
type navigationEventPayload = {
5+
.
6+
"action": NavigationActions.action,
7+
"context": string,
8+
"type": string,
9+
"state": NavigationState.t,
10+
"lastState": Js.Nullable.t(NavigationState.t),
11+
};
12+
313
[@bs.val] [@bs.module "react-navigation"]
414
external navigationContext: React.Context.t(t) = "NavigationContext";
515

@@ -14,7 +24,17 @@ external navigateWithParams: (t, string, Js.t({..})) => unit = "navigate";
1424
[@bs.send] external goBackToRoute: (t, string) => unit = "";
1525
[@bs.send] external getParam: (t, string) => Js.nullable('a) = "";
1626
[@bs.send] external getParamWithDefault: (t, string, 'a) => 'a = "getParam";
17-
// TODO: addListener, setParams, ...
27+
[@bs.send]
28+
external addListener:
29+
(
30+
t,
31+
[@bs.string] [ | `didBlur | `didFocus | `willBlur | `willFocus],
32+
navigationEventPayload => unit
33+
) =>
34+
EventSubscription.t =
35+
"addListener";
36+
37+
// TODO: setParams, ...
1838
// Stack Actions
1939
// TODO: push, replace, ...
2040
[@bs.send] external pop: t => unit = "";

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /