Skip to content

Instantly share code, notes, and snippets.

@hew
Forked from mhallin/App.re
Last active Jan 18, 2019
Embed
What would you like to do?
Async import pattern

async import pattern in reasonml

PageModule.fetchModule("./MyComponent")
|> Js.Promise.then_(m => send(SetRootElement(m())));
let component = ReasonReact.statelessComponent("MyComponent");
let make = (_) => {
...component,
render: (_) => <div />
};
let make = () => make([||]);
include PageModule.M;
module type M = {
let make: unit => ReasonReact.reactElement;
};
type m = Js.t({ . make: unit => ReasonReact.reactElement });
[@bs.val] external fetchModule: string => Js.Promise.t(m) = "import";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment