Hi all, I'm a newbie in Elm — and I already love it. Is this list suitable for beginners with (probably the silliest) doubts? If not, my apologies, delete this email and move on ; )
I'm writing a stopwatch <https://github.com/cuducos/cunhajacaiu/blob/elm/cunhajacaiu/static/elm/Stopwatch.elm> to study Elm — replacing something in a legacy tiny project that used to be in ReactJS. (In other news: this study project made me write a webassets filter to compile Elm <https://twitter.com/cuducos/status/742698891343204353> files, hello Python world). The stopwatch itself is working fine. I load it in the proper DOM element and it starts counting seconds, minutes, hours, days etc… However I would like to set a starting count for the stopwatch — that is to say, instead of staring with* 0 days, 0 hours, 0 minutes and 0 seconds*, I would like it to start with (for example) *33 days, 20 hours, 17 minutes and 45 seconds*. I would load this data from an API <http://www.cunhajacaiu.com.br/api/stopwatch/> (JSON) or from the DOM itself: <div id="stopwatch" data-days="57" data-hours="13" data-minutes="7" data-seconds="2"> ... </div> First I thought that loading from the API was easier, but to run the HTTP request and parse the JSON was a bit troublesome for a beginner. Then I tried to use *ports*: I defined a ports module, but couldn't get my types right. For examples, one of the things I tried: -- snippet from ports module port load : { days: Int , hours: Int , minutes: Int , seconds: Int } -> Cmd Got me: 4| port load : { days: Int , hours: Int , minutes: Int , seconds: Int } -> Cmd ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ You are saying it should be: { days : Int, hours : Int, minutes : Int, seconds : Int } -> Platform.Cmd.Cmd But you need to use the particular format described here: <http://guide.elm-lang.org/effect_managers/> And honestly I couldn't figure out how this URL would help me. Just in case, In my Javascript I had: var stopwatchContainer = document.getElementById('stopwatch'); if (stopwatchContainer !== null) { var app = Elm.Stopwatch.embed(stopwatchContainer); app.ports.load.send(stopwatchContainer.dataset); } Any idea on how to implement that (whether it is via API or ports)? Replies, links, chats, pair programming, pull requests… anything is more than welcomed ; ) Many thanks, Eduardo Cuducos http://cuducos.me/ -- You received this message because you are subscribed to the Google Groups "Elm Discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
