Handle chunked data sent by Play scala with AngularJs

All we need is an easy explanation of the problem, so here it is.

I send chunked data with Play Scala 2.2 to the client side like this : Ok.chunked(data)

I would like to use them as soon as they are available on the client side. If I just get the data and print them on .success, they are printed at the same time i.e. when the last data is received.

How can I print them as soon as they are received? Must I use websockets?

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

Use streaming json library like http://oboejs.com/

Oboe.js is an open source Javascript library for loading JSON using streaming, combining the convenience of DOM with the speed and fluidity of SAX.

It can parse any JSON as a stream, is small enough to be a micro-library, doesn’t have dependencies, and doesn’t care which other libraries you need it to speak to.

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply