aboutsummaryrefslogtreecommitdiffstats
path: root/src/js
diff options
context:
space:
mode:
authorJakub Hampl <kopomir@gmail.com>2018-08-21 15:51:05 +0100
committerGitHub <noreply@github.com>2018-08-21 15:51:05 +0100
commitaf8b5c077da700236667ccb3cdcd736774dd9e3b (patch)
tree5472d2c8fdf9cc81948a822e89672a0d74e5e0f3 /src/js
parent11d932001ed65fed690b835e5eef504f90845533 (diff)
v0.19 compatibility (#1)
Diffstat (limited to 'src/js')
-rw-r--r--src/js/main.js30
1 files changed, 19 insertions, 11 deletions
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;