DEV Community

Discussion on: Elm in the server (or anywhere else) with promises

Collapse
 
rupertlssmith profile image
Rupert Smith • Edited

Might also be worth taking a look at package.elm-lang.org/packages/the-...

This follows the same model described above - the request (and response) comes into a subscription port, and the filled in response goes back out a port. The elm-serverless framework ties those 2 things together by maintaining a connection id and letting you have a Model as context over the whole request/response cycle.

elm-serverless has a modified XMLHttpRequest object, that lets you use elm/http just as you would in a browser application. Your HTTP requests will trigger events in the application with the correct context attached.

It can run in standalone mode too, not just for deploying to the cloud, although the standalone mode is more meant for development.

One issue is requests with binary data - since Elm ports cannot pass Bytes. There is probably a workaround for this by putting the data in a File which can go through a port.

Collapse
 
eberfreitas profile image
Éber Freitas Dias

That is awesome!