I have a setInterval()
function in a component class that fires off every 1/10 of a second. All it does is update a d3 graph and does not touch any angular bindings.
By default setInterval()
triggers the change detection in angular from the root node.
Is there a way to run the setInterval()
function without triggering any change detection?
I don't need the rest of the app to update itself since I know this only affects the graph and d3 is the only one responsible for the updating the graph.
Click on "Enable Change Detection" from the given list. Select "Enable" or "Disable" operation based on your requirement. If you select Disable, skip to the last step.
How is change detection implemented? Angular can detect when component data changes, and then automatically re-render the view to reflect that change.
Angular runs its change detection mechanism periodically so that changes to the data model are reflected in an application's view. Change detection can be triggered either manually or through an asynchronous event (for example, a user interaction or an XMLHttpRequest completion).
detectChanges()link Checks this view and its children. Use in combination with detach to implement local change detection checks.
You have to run it outside of angular. Take a look at this answer to a similar question.
https://stackoverflow.com/a/39626378/1710501
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With