This example demonstrates how the default
field/property name somehow causes a problem when
passing data into an Elm application through a port.
Last active
November 13, 2015 23:10
-
-
Save fredcy/f6d2a7aba81f143916e8 to your computer and use it in GitHub Desktop.
Show problem passing 'default' field name though elm port.
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
import Html exposing (..) | |
type alias Info = { default : String, default1 : String } | |
main : Html | |
main = | |
-- Access and display both fields as obtained through the port to show how the | |
-- "default" field value does not get through. | |
let m = startingState | |
val = ( m.default, m.default1 ) | |
in | |
div [] | |
[ div [] [ startingState |> toString |> text ] | |
, div [] [ val |> toString |> text ] | |
] | |
port startingState : Info |
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
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<title>Default test</title> | |
<script type="text/javascript" src="elm.js"></script> | |
</head> | |
<body> | |
<h1>Default test</h1> | |
</body> | |
<script> | |
var startingState = { 'default' : 'foobar', 'default1' : 'larry' }; | |
var test = Elm.fullscreen(Elm.Main, { startingState: startingState }); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment