Questions tagged [elm-port]

Use for questions involving the use of ports for javascript interop in [elm]. Prefer to also tag with [ffi) to indicate javascript interop more generally, as ports are not the only and may not be the best tool for the job of interoperating with javascript.

Ports is a form of in that permit communication with native . Other forms of JavaScript interop in Elm include flags and custom elements.

11 questions
14
votes
6 answers

Cmd to simply go to a new webpage in Elm

Is there a way to simply go to a new webpage in Elm, similar to clicking on a link? I have a button that when clicked I want to take the user to another webpage. I know I could make that an a element and use CSS to style it like a button. However,…
at.
  • 50,922
  • 104
  • 292
  • 461
12
votes
4 answers

How to auto-scroll to the bottom of a div in Elm

I add
s to a wrapper
and I need to be able to scroll to the last one added each time. How do I do this in Elm?
Anonymous: Hello
John:…
at.
  • 50,922
  • 104
  • 292
  • 461
10
votes
1 answer

elm: define subscription port with no parameters

Is there a way to define a subscription port with no parameters in Elm? Something like: port updateTime : () -> Sub msg With this code, I'm getting the error that "Port 'updateTime' has an invalid type" With the code: port updateTime : (String ->…
Buda Gavril
  • 21,409
  • 40
  • 127
  • 196
4
votes
1 answer

Calling a port after view is updated in Elm

Is there a straightforward way to have a Cmd execute after the view is updated? In particular, I’m trying to reposition the cursor in a textarea upon specific keys (like the enter key) being pressed. In my update function I have: case…
at.
  • 50,922
  • 104
  • 292
  • 461
4
votes
2 answers

Is there an embeddable code editor for Elm?

I want to have a code editor widget, like CodeMirror or Ace, in my Elm webpage. Unfortunately, CodeMirror and Ace don't work with Elm as they modify the DOM (at least that's my understanding why they don't work). I need something at least better…
at.
  • 50,922
  • 104
  • 292
  • 461
2
votes
2 answers

How to read cookies in Elm?

I've learned in this SO question that there currently is no simple way to turn cookie-based CSRF tokens into HTTP request headers in Elm. Thus, to write a single page application (SPA) that works nicely with a Django Rest Framework backend, I need…
Ulrich Schuster
  • 1,670
  • 15
  • 24
1
vote
1 answer

Elm : Pass value to outgoing port from the update function

I have an update function that adds an Answer to a Question Once the question has been updated with an answer, I'd like to send it to an outgoing port, while also updating my model. port emitQuestion : Question -> Cmd msg update msg model = …
Denim Demon
  • 734
  • 1
  • 10
  • 23
1
vote
1 answer

Using ports with elm-app

I'm trying to use ports with elm-app. Previously I used elm-live and a vanilla setup, and was able to insert ports like this: index.html
Mark Karavan
  • 2,654
  • 1
  • 18
  • 38
1
vote
1 answer

Elm output port is not working with a signal derived from StartApp

We're learning Elm basics and building a simple application with some audio output with the following setup: We are using Elm's StartApp. We have ports/audio.js with some POC audio logic (and console.log). ATM we are using elm-live to run the…
Touko
  • 11,359
  • 16
  • 75
  • 105
0
votes
1 answer

Can't decode session from elm port

Trying to get elm ports working to maintain the session. In index.html, the script includes the following listener: window.addEventListener("load", function(event) { app.ports.onSessionChange.send(localStorage.session); },…
Mark Karavan
  • 2,654
  • 1
  • 18
  • 38
0
votes
2 answers

Ports and DOM rendering

Try to use CodeMirror in my Elm app. I bind a textarea from update function like that: ( ..., runCodemirror textAreaId) Where runCodemirror is a port: port runCodemirror : String -> Cmd msg Problem is that event ports.runCodemirror fires before a…
ztsu
  • 25
  • 7