3

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?

vorant
  • 708
  • 5
  • 15
  • https://stackoverflow.com/questions/43108155/angular-2-how-to-keep-event-from-triggering-digest-loop – eko Apr 13 '17 at 18:53

1 Answers1

2

you may try runOutsideAngular for your websocket calls.

Read more about it here.

Hope this helps!!

Madhu Ranjan
  • 17,334
  • 7
  • 60
  • 69