Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude websocket from zonejs

I am rewriting app based on angular 1 to angular 2. In my app there is websockets. Each time when app gets message from websocket it runs zone.runTask (because websocket.onmessage is async function) and in the end it update $digest circle from angular1. This is normal behaviour. But app gets ~3000 websocket messages per second and zonejs runs with $digest circle 3000 times per second and it spoils performance up to freeze.

I want to exclude websocket.onmessage from zonejs control, wait untill all messages will be downloaded and then run zonejs using setTimeout function.

So my questions are: Is there a way to exclude websocket.onmessage from zonejs control? Or how to get back standart websocket.onmessage behaviour without monkey patching by zonejs?

like image 481
vorant Avatar asked Sep 08 '26 05:09

vorant


1 Answers

you may try runOutsideAngular for your websocket calls.

Read more about it here.

Hope this helps!!

like image 86
Madhu Ranjan Avatar answered Sep 11 '26 06:09

Madhu Ranjan