cramertj / domafic-rs

MIT License
146 stars 5 forks source link

How are side effects managed #9

Open iqualfragile opened 7 years ago

iqualfragile commented 7 years ago

this is more of a question then an issue, but what is the story for side effects, is there one? like when you want to send a message through a websocket, or retrieve some resource via http

cramertj commented 7 years ago

Right now, there's no built-in system for IO. The WIP http branch defines a 'JsIo' type that allows you to send HTTP requests and handle the result in a callback. I'd prefer promises, but I haven't yet worked out exactly how I'd like those to look. If you have ideas, please share!

jimmycuadra commented 7 years ago

The JsIo API has been published since the last comment here, but I'm wondering about other types of interoperation with JavaScript code. For example, getting the current time, or calling a JavaScript function being included in the global context. That type of interoperation is one of the more unpleasant parts of Elm, so I'm hoping something easier will be available in Domafic. :}

iqualfragile commented 7 years ago

while the way side effects are handled in elm seems a bit weird from a non-fp point of view, having managed side effects is extremly important to the elm architecture and makes it what it is.

cramertj commented 7 years ago

@jimmycuadra Just to give some context-- I'm trying to come up with a way to allow for both calling/receiving messages from JavaScript that prevents unnecessary allocations, but that also correctly handles Domafic code that calls Javascript that calls back to Domafic code. I've got a few things in mind, and I've written a few prototypes, but I don't have anything to show just yet. I'll update this issue when I have a more concrete idea for how this could look.