Skip to content

Commit

Permalink
Fix navigateBy* functions (#46)
Browse files Browse the repository at this point in the history
- `navigateBy` didn't accept `navigation`
  • Loading branch information
vknez authored Sep 20, 2021
1 parent e077974 commit b89bf1e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
16 changes: 8 additions & 8 deletions src/Core.bs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
var Caml_option = require("rescript/lib/js/caml_option.js");

function NavigationHelpersCommon(M) {
var navigateByKey = function (key, params, param) {
var navigateByKey = function (key, params, navigation) {
var tmp = {
key: key
};
if (params !== undefined) {
tmp.params = Caml_option.valFromOption(params);
}
tmp.navigate();
navigation.navigate(tmp);

};
var navigateByName = function (name, key, params, param) {
var navigateByName = function (name, key, params, navigation) {
var tmp = {
name: name
};
Expand All @@ -23,7 +23,7 @@ function NavigationHelpersCommon(M) {
if (params !== undefined) {
tmp.params = Caml_option.valFromOption(params);
}
tmp.navigate();
navigation.navigate(tmp);

};
return {
Expand All @@ -37,17 +37,17 @@ function EventConsumer(M) {
}

function NavigationScreenProp(M) {
var navigateByKey = function (key, params, param) {
var navigateByKey = function (key, params, navigation) {
var tmp = {
key: key
};
if (params !== undefined) {
tmp.params = Caml_option.valFromOption(params);
}
tmp.navigate();
navigation.navigate(tmp);

};
var navigateByName = function (name, key, params, param) {
var navigateByName = function (name, key, params, navigation) {
var tmp = {
name: name
};
Expand All @@ -57,7 +57,7 @@ function NavigationScreenProp(M) {
if (params !== undefined) {
tmp.params = Caml_option.valFromOption(params);
}
tmp.navigate();
navigation.navigate(tmp);

};
return {
Expand Down
14 changes: 9 additions & 5 deletions src/Core.res
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,17 @@ module NavigationHelpersCommon = (
unit,
) => navigationParams = ""

@send external navigateBy: navigationParams => unit = "navigate"
@send external navigateBy: (navigation, navigationParams) => unit = "navigate"

let navigateByKey = (~key: string, ~params: option<M.params>=?, _) =>
navigateBy(navigateByKeyParams(~key, ~params?, ()))
let navigateByKey = (~key: string, ~params: option<M.params>=?, navigation) =>
navigateBy(navigation, navigateByKeyParams(~key, ~params?, ()))

let navigateByName = (~name: string, ~key: option<string>=?, ~params: option<M.params>=?, _) =>
navigateBy(navigateByNameParams(~name, ~key?, ~params?, ()))
let navigateByName = (
~name: string,
~key: option<string>=?,
~params: option<M.params>=?,
navigation,
) => navigateBy(navigation, navigateByNameParams(~name, ~key?, ~params?, ()))

@send external replace: (navigation, string) => unit = "replace"
@send
Expand Down

0 comments on commit b89bf1e

Please sign in to comment.