使用AngularJs处理Play scala发送的分块数据 [英] Handle chunked data sent by Play scala with AngularJs
问题描述
我将带有Play Scala 2.2
的chunked data
发送到客户端,如下所示:Ok.chunked(data)
I send chunked data
with Play Scala 2.2
to the client side like this : Ok.chunked(data)
我想在客户端上尽快使用它们.如果我只是获取数据并将其打印在.success
上,则它们将在同一时间(即接收到最后一个数据时)进行打印.
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.
如何在收到它们后立即打印它们?我必须使用websockets
吗?
How can I print them as soon as they are received? Must I use websockets
?
推荐答案
使用流式json库,例如 http://oboejs.com/
Use streaming json library like http://oboejs.com/
Oboe.js是一个开放源代码Javascript库,用于使用流技术加载JSON,将DOM的便利性与SAX的速度和流畅性结合在一起.
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.
它可以将任何JSON解析为流,足够小以成为微库,没有依赖关系,并且不在乎您需要与之对话的其他库.
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.
这篇关于使用AngularJs处理Play scala发送的分块数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!