From 4137773928b4fa52bcb382076c8a5bb68e5617a1 Mon Sep 17 00:00:00 2001 From: Dillon Kearns Date: Fri, 16 Oct 2020 10:36:12 -0700 Subject: [PATCH] Import user-index in example. --- examples/simple/index.js | 9 ++++++--- examples/simple/user-index.js | 9 +++++++++ generator/src/cli.js | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 examples/simple/user-index.js diff --git a/examples/simple/index.js b/examples/simple/index.js index 73fe0e26..f92daca9 100644 --- a/examples/simple/index.js +++ b/examples/simple/index.js @@ -1,6 +1,7 @@ // @ts-ignore // const { Elm } = require("./src/Main.elm"); import { Elm } from "/main.js"; +import userInit from "/user-index.js"; // const pagesInit = require("../../index.js"); let prefetchedPages; @@ -159,9 +160,11 @@ function httpGet(/** @type string */ theUrl) { }); } -pagesInit({ - mainElmModule: Elm.Main, -}); +userInit( + pagesInit({ + mainElmModule: Elm.Main, + }) +); // function pagesInit(config) { // const path = window.location.pathname.replace(/(\w)$/, "$1/"); diff --git a/examples/simple/user-index.js b/examples/simple/user-index.js new file mode 100644 index 00000000..479f424b --- /dev/null +++ b/examples/simple/user-index.js @@ -0,0 +1,9 @@ +export default function (elmLoaded) { + console.log("Hello outside of promise!"); + elmLoaded.then((elmPagesApp) => { + console.log("Inside of promise"); + elmPagesApp.ports.example.subscribe((message) => { + console.log("Elm port message: ", message); + }); + }); +} diff --git a/generator/src/cli.js b/generator/src/cli.js index 3e926515..5f7e35f1 100644 --- a/generator/src/cli.js +++ b/generator/src/cli.js @@ -129,6 +129,7 @@ async function runTerser(filePath) { async function copyAssets() { fs.copyFile("index.js", "dist/index.js"); + fs.copyFile("user-index.js", "dist/user-index.js"); fs.copyFile("style.css", "dist/style.css"); }