I’m currently trying to convert everything I’ve been doing through native to work via ports. For the most part, it’s possible.
But where I’m really getting stuck is the most complex part of my native code: a decoder.
Most of my native code use is to just run some methods, but I have one part of a Json value I currently decode using native. It’s the TimeRange object, represented in JavaScript as { length: index, { start: start(index), end: end(index) }. See [here] (https://developer.mozilla.org/en-US/docs/Web/API/TimeRanges)
I have a native function that takes a value, loops through and returns a list of {start: Float, end: Float}. It’s part of a pipeline decoder of much larger object, that I decode from the eventTarget on a custom “on” function.
I’d really, really like to keep decoding the object in Elm, as a pipeline, but I have no clue how to send this Json value through a port, then wait for a subscription to plug it into the Json decoder. What’s more, there are use cases where I care about frame accuracy, and need a response in less than 1/60 seconds. It’s really not viable for this information to be delayed more than a single requestAnimationFrame.
Any ideas? Is this just impossible? Really hitting a wall here on something that’s my primary elm project.