如何创建一个Node.js的API,可以发送进度指示数据的前视图? [英] How to create a Node.js API that can send progress indication data to the front view?

查看:151
本文介绍了如何创建一个Node.js的API,可以发送进度指示数据的前视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的平均项目作为我的爱好。我用Node.js的作为后端和Angular.js为前端。 Node.js的将执行一个长期持久的任务(这大约需要30分钟来执行这个任务),我要显示的视图页上的任务状态。我怎样才能做到这一点?

I'm working on a MEAN project as my hobby. I use Node.js as the back end and Angular.js as the front end. Node.js will execute a long lasting task (it takes about 30 minutes to execute this task), I want to display the task status on the view page. How can I achieve this?

推荐答案

我想你所谈论的是一个流的请求。
看看这个 http://strongloop.com/strongblog/streaming -chunked-HTML节点-JS-数据/

I think what you are talking about is a streamed request. Take a look at this http://strongloop.com/strongblog/streaming-chunked-html-node-js-data/.

而在前端有一个叫EventSource的Javascript API第方法可以读取流响应或别人提到的,如果你需要双向通信,您可以使用套接字。

And in the front-end there is a Javascript API method called EventSource that can read a streamed response or as someone else mentioned you can use sockets if you need bi-directional communication.

这篇关于如何创建一个Node.js的API,可以发送进度指示数据的前视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆