On Wednesday, 28 December 2016 15:33:25 UTC+7, Peter Damoc wrote: > > > > On Wed, Dec 28, 2016 at 9:06 AM, Mark Hamburg <[email protected] > <javascript:>> wrote: > >> Just to make it clear, I'm not particularly calling for an easier way to >> create "subscriptions". I'm calling for a way to do one of the following — >> either is fine, each have their pluses and minuses: >> >> 1. Expose a synchronous, externally defined function that takes JSON (or >> really anything a command port supports) in and returns JSON (or really >> anything a subscription port supports) out. >> - or - >> 2. Expose a factory for externally defined asynchronous tasks where the >> task when executed receives JSON (etc) in and resolves to JSON (etc) when >> finished. >> > > 1. would break the purity guarantee. > > 2. this looks like the mechanism for scheduling messages. In short, if one > could schedule a message to be delivered after the execution of some JS > function, one could accomplish what you want. > > I'm not familiar with how difficult would be to expose this functionality > in the ports world. The functionality exists in the Native layer as one can > see in the Native implementation of Time.now but exposing it in a safe and > easy way through the ports API might not be trivial. >
It looks like the implementation of this StackOverflow answer <http://stackoverflow.com/a/40334086/549617> (ignore the question and relevance as it is old, but the calling a function `getParentPos ()` to get some answers through some JavaScript called through a port, which returns the answers through a subscription `parentPos`that fires a message to update should still work. This is fine as long as there is only one subscription, but as Mark says there is no Event Manager so it would likely get confused if there were other subscriptions such as say `Timer.every`. If this worked generally, it would be an easy way to transfer to a long running program written in JavaScript, with that long running program able to fire progress reports back and even a different completion Msg, but would be fairly useless if it didn't work with other subscriptions without adding a lot of code. -- 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.
