Skip to content

Instantly share code, notes, and snippets.

@farmisen
Created May 3, 2020 15:52
Show Gist options
  • Save farmisen/0e4d5bf073d4604577d2bead7f07ecab to your computer and use it in GitHub Desktop.
Save farmisen/0e4d5bf073d4604577d2bead7f07ecab to your computer and use it in GitHub Desktop.
aws amplify bindings
// aws-amplify
type t;
[@bs.module "aws-amplify"] external amplify: t = "default";
module Configure = {
type config;
[@bs.module "../aws-exports.js"] external awsConfig: config = "default";
[@bs.send] external configure: (t, config) => unit = "configure";
let configure = (config: config) => configure(amplify, config);
};
let configure = (config: Configure.config) => Configure.configure(config);
// @aws-amplify/auth
module Auth = {
type t;
[@bs.module "@aws-amplify/auth"] external auth: t = "Auth";
[@bs.send]
external currentAuthenticatedUser: t => Js.Promise.t('a) =
"currentAuthenticatedUser";
let currentAuthenticatedUser = () => currentAuthenticatedUser(auth);
};
// @aws-amplify/core
module Hub = {
type t;
[@bs.module "@aws-amplify/core"] external hub: t = "Hub";
[@bs.send] external listen: (t, string, 'a) => unit = "listen";
let listen = (channel: string, callback: 'a) =>
listen(hub, channel, callback);
[@bs.send] external remove: (t, string) => unit = "remove";
let remove = (channel: string) => remove(hub, channel);
};
// @aws-amplify/ui-react
[@bs.module "@aws-amplify/ui-react"]
external withAuthenticator:
(React.component('props), bool) => React.component('props) =
"withAuthenticator";
module Authenticator = {
[@bs.module "@aws-amplify/ui-react"] [@react.component]
external make:
(~initialAuthState: string=?, ~children: React.element=?) => React.element =
"AmplifyAuthenticator";
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment