So, I have a backend (Python flask) that traverses a large graph to create the transitive hull starting from a specific node, i.e. all reachable nodes from that node. It then wraps the result in Json and sends it off to an Elm front end.
Now I’m thinking to use flask’s streaming pattern to send parts of the list of nodes already while it’s being discovered, to provide early feedback to the user.
Is there a way to partially decode Json in Elm and treat it as a stream, e.g. through a subscription?
Elm’s Http module does not allow that, but it does let you show a progress bar if your backend can predict the size of the response.
To access data from a request while it’s being received, you need to do the request in JavaScript and use ports. Then use or create a JSON parser that works with streaming data.
If the backend can quickly access a node when given an ID, then there’s another solution: make the backend send only the node IDs in the first response, then the frontend can make one request for each node to get the nodes’ data.
Thanks for the quick response. I’m aware of the progress feature but unfortunately the response size is pretty unpredictable. Sigh, I guess I’ll have to resort to JS like you suggested.