From af8b5c077da700236667ccb3cdcd736774dd9e3b Mon Sep 17 00:00:00 2001
From: Jakub Hampl <kopomir@gmail.com>
Date: Tue, 21 Aug 2018 15:51:05 +0100
Subject: v0.19 compatibility (#1)

---
 src/js/main.js | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

(limited to 'src/js/main.js')

diff --git a/src/js/main.js b/src/js/main.js
index eff72ed..e56533c 100644
--- a/src/js/main.js
+++ b/src/js/main.js
@@ -1,18 +1,13 @@
 import mapboxgl from "mapbox-gl";
 
-function wrapElmApplication(elmApp, settings = {}) {
+
+export function registerCustomElement(settings) {
   const options = Object.assign(
     {
-      outgoingPort: "elmMapboxOutgoing",
-      incomingPort: "elmMapboxIncoming",
-      easingFunctions: {
-        linear: t => t
-      },
       onMount() {}
     },
     settings
   );
-
   if (options.token) {
     mapboxgl.accessToken = options.token;
   }
@@ -279,8 +274,21 @@ function wrapElmApplication(elmApp, settings = {}) {
       }
     }
   );
+}
 
-  if (elmApp.ports && elmApp.ports.elmMapboxOutgoing) {
+export function registerPorts(elmApp, settings = {}) {
+  const options = Object.assign(
+    {
+      outgoingPort: "elmMapboxOutgoing",
+      incomingPort: "elmMapboxIncoming",
+      easingFunctions: {
+        linear: t => t
+      }
+    },
+    settings
+  );
+
+  if (elmApp.ports && elmApp.ports[options.outgoingPort]) {
     function processOptions(opts) {
       if (opts.easing) {
         return Object.assign({}, opts, {
@@ -353,11 +361,11 @@ function wrapElmApplication(elmApp, settings = {}) {
           });
       }
     });
+  } else {
+    throw new Error(`Expected Elm App to expose ${elmApp.ports[options.outgoingPort]} port.`);
   }
 
   return elmApp;
 }
 
-wrapElmApplication.supported = mapboxgl.supported;
-
-export default wrapElmApplication;
+export const supported = mapboxgl.supported;
-- 
cgit v1.2.3