Created
June 10, 2016 14:32
-
-
Save glenjamin/71e53938a1e7a3b3a20c3056bc47f9c6 to your computer and use it in GitHub Desktop.
A sketch of an approach for making it slightly easier to share elm native modules.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function ElmNativeWrapper(name, actualNativeModule) { | |
var initialised = false; | |
window[name] = { | |
init: function(appname) { | |
// Could use Object.keys(window) here to try and detect if the name is wrong | |
window[munge(appname) + "$Native_" + name] = actualNativeModule(); | |
initialised = true; | |
} | |
} | |
setTimeout(function() { | |
if (!initialised) { | |
console.error("Native module " + name + " was not initialised"); | |
} | |
}, 1000); | |
function munge() { | |
// TODO | |
} | |
})( | |
"ElmFirebase", | |
function actualNativeModule() { | |
return { | |
whatever: "you", | |
need: "here" | |
}; | |
} | |
); | |
ElmFirebase.init("glenjamin/haxx"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment