Permalink
Browse files

bindings for Dialog

  • Loading branch information...
zploskey committed Mar 23, 2018
1 parent 529a653 commit 1b9594bb07ac66d8beba22a87194e0fd8b5ba377
Showing with 56 additions and 0 deletions.
  1. +39 −0 lib/js/src/Dialog.js
  2. +17 −0 src/Dialog.re
@@ -0,0 +1,39 @@
'use strict';

var Js_mapperRt = require("bs-platform/lib/js/js_mapperRt.js");

var jsMapperConstantArray = /* array */[
/* tuple */[
-581181762,
"beforeunload"
],
/* tuple */[
272211200,
"confirm"
],
/* tuple */[
562976604,
"alert"
],
/* tuple */[
894980516,
"prompt"
]
];

function dialogTypeToJs(param) {
return Js_mapperRt.binarySearch(4, param, jsMapperConstantArray);
}

function dialogTypeFromJs(param) {
return Js_mapperRt.revSearch(4, jsMapperConstantArray, param);
}

function type_(dialog) {
return dialogTypeFromJs(dialog.type());
}

exports.dialogTypeToJs = dialogTypeToJs;
exports.dialogTypeFromJs = dialogTypeFromJs;
exports.type_ = type_;
/* No side effect */
@@ -0,0 +1,17 @@
type t;

[@bs.deriving jsConverter]
type dialogType = [ | `alert | `beforeunload | `confirm | `prompt];

[@bs.send]
external accept : (t, ~promptText: string=?, unit) => Js.Promise.t(unit) = "";

[@bs.send] external defaultValue : t => string = "";

[@bs.send] external dismiss : t => Js.Promise.t(unit) = "";

[@bs.send] external message : t => string = "";

[@bs.send] external typeString : t => string = "type";

let type_ = dialog => dialogTypeFromJs(typeString(dialog));

0 comments on commit 1b9594b

Please sign in to comment.