简体   繁体   English

如何在Angular.js服务中正确包装GAE Channel API并将更新推送到整个应用程序?

[英]How to properly wrap GAE Channel API in Angular.js service and push updates out to the entire app?

So I'm trying to use the GAE Channel API with Angular.js to do real-time data-bound updates (which would be really cool, right!?). 所以我正在尝试使用带有Angular.jsGAE Channel API来进行实时数据绑定更新(这真的很酷,对吧!?)。 I'm told the correct way to do this is to wrap the Channel API Javascript Client in an Angular.js service ( and make sure to use $apply() ). 我被告知正确的方法是将Channel API Javascript客户端包装在Angular.js服务中( 并确保使用$ apply() )。 But what does that mean exactly? 但那究竟是什么意思呢?

To my understanding, for the Channel API, I'm pretty much supposed to have a 1:1 client:channel connection, so all my updates will have to flow down that one channel for all the models in my entire app. 根据我的理解,对于Channel API,我几乎应该有一个1:1的客户端:频道连接,所以我的所有更新都必须在我的整个应用程序中为所有模型向下流动一个频道。 How do I then broadcast to possibly multiple scopes that a model (generally an ngResource) has been updated? 然后,我如何向可能的多个范围广播模型(通常是ngResource)已更新? $watch? $看? $emit? $发出? $broadcast? $广播? $digest? $消化?

I had the same requirement and solved it with an Angular service. 我有相同的要求,并通过Angular服务解决了它。 I described my solution here : 我在这里描述了我的解答:

http://david-codes.blogspot.com/2013/03/app-engine-channel-api-and-angular-js.html http://david-codes.blogspot.com/2013/03/app-engine-channel-api-and-angular-js.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM