Created
August 30, 2017 19:28
-
-
Save nqthqn/a1a317aad39e70fc40e6a93a2b048efb to your computer and use it in GitHub Desktop.
Porting to Js
This file contains 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
var app = Elm.Main.fullscreen() | |
app.ports.set.subscribe(function(keyValue) { | |
var [key, value] = keyValue | |
window.localStorage.setItem(key, | |
JSON.stringify(value) | |
) | |
}) | |
app.ports.remove.subscribe(function(key) { | |
localStorage.removeItem(key) | |
}) | |
app.ports.clear.subscribe(function(i) { | |
localStorage.clear() | |
}) |
This file contains 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
port module Ports exposing (..) | |
import Json.Encode | |
type alias Key = | |
String | |
type alias Value = | |
Json.Encode.Value | |
port set : ( Key, Value ) -> Cmd msg | |
port remove : Key -> Cmd msg | |
port clear : () -> Cmd msg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment