Skip to content

Commit

Permalink
Merge pull request facebook#58 from mbirkegaard/master
Browse files Browse the repository at this point in the history
Fixed bindings for the Linking module.
  • Loading branch information
wokalski authored Aug 15, 2017
2 parents 74cfd3e + f6c9d72 commit c178216
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
17 changes: 10 additions & 7 deletions src/linkingRe.re
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
external openURL : string => Js.Promise.t unit =
"openUrl" [@@bs.scope "Linking"] [@@bs.module "react-native"];
"openURL" [@@bs.scope "Linking"] [@@bs.module "react-native"];

external _canOpenUrl : string => Js.Promise.t Js.boolean =
"canOpenUrl" [@@bs.scope "Linking"] [@@bs.module "react-native"];
external _canOpenURL : string => Js.Promise.t Js.boolean =
"canOpenURL" [@@bs.scope "Linking"] [@@bs.module "react-native"];

let canOpenUrl url =>
_canOpenUrl url |> Js.Promise.then_ (fun bool => Js.Promise.resolve (Js.to_bool bool));
let canOpenURL url =>
_canOpenURL url |> Js.Promise.then_ (fun bool => Js.Promise.resolve (Js.to_bool bool));

external getInitialUrl : unit => Js.Promise.t string =
"getInitialUrl" [@@bs.scope "Linking"] [@@bs.module "react-native"];
external _getInitialURL : unit => Js.Promise.t (Js.Null.t string) =
"getInitialURL" [@@bs.scope "Linking"] [@@bs.module "react-native"];

let getInitialURL () =>
_getInitialURL () |> Js.Promise.then_ (fun stringOrNull => Js.Promise.resolve (Js.Null.to_opt stringOrNull));

external addEventListener : string => (Js.t {. url : string} => unit) => unit =
"" [@@bs.scope "Linking"] [@@bs.module "react-native"];
Expand Down
7 changes: 3 additions & 4 deletions src/linkingRe.rei
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
let canOpenUrl: string => Js.Promise.t bool;
let canOpenURL: string => Js.Promise.t bool;

external openURL : string => Js.Promise.t unit =
"openUrl" [@@bs.scope "Linking"] [@@bs.module "react-native"];
"openURL" [@@bs.scope "Linking"] [@@bs.module "react-native"];

external getInitialUrl : unit => Js.Promise.t string =
"getInitialUrl" [@@bs.scope "Linking"] [@@bs.module "react-native"];
let getInitialURL : unit => Js.Promise.t (option string);

external addEventListener : string => (Js.t {. url : string} => unit) => unit =
"" [@@bs.scope "Linking"] [@@bs.module "react-native"];
Expand Down

0 comments on commit c178216

Please sign in to comment.