If you are building a large app then you must optimize code by implementing manual change detection process. This video shows how to use change detection strategy in Angular.
Thanks for video, I am Passing for one problem in my job. The data update only if I to click on the screen or to put one event click()… I am go to test this…
The slice function returns with a new string and does not modify the original one. So if you do not save the result of the slice operation in a new var, then the result is lost. The reason you see "example" after the slice is because you are printing the original one, you did not save the result in a new var. Although strings are indeed inmutable, this is not a good reasoning.
question - should i use onPush in every component in my app which has an @input? or only in components with long lists of component (that can hurt my performance) thanks!
Thanks Saikat. This video help me a lots to understand change detection methodology but i have two questions in my mind: 1).changeDetectionStrategy.onpush will only work when reference of object changed then What does the difference make mutable or immutable objects. 2). Why should we use detect or detach method of changeDectorRef ? changeDetectionStrategy.onpush will work as same, in your video if we want to detach changes then we can use changeDetectionStrategy.default and if want to detect than we can use changeDetectionStrategy.onpush . Can you please help to understand we should use changeDectorRef.
For #1 a mutable object is one where its state can be changed and still point to the same reference, while an immutable is an object which cannot change its state. To 'change' it, It requires you to create a whole new object with the changes and reassign it back. Mutable means 'capable of change', while 'immutable' means 'not susceptible to change'. You can think of this 'clone and reassign' process for immutable objects as a sort of 'push'. Hence 'changeDetectionStrategy.onpush'. For #2 I believe the changeDetectorRef allows fine grained control of when these 'change processing' features happen within your code.
Hi, nice work! Do you know if there is a way I can detach change detector and centralize detectChanges into an event for a child component? I only got it calling detectChanges every place I needed it.
Thanks for awesome video. Love the concrete and easy to follow example.
Awesome video. best explanation for change detection strategy
thanks bro for your valuable examples. 🙏
This video answers many other questions and also encouraged us to read more about interesting js questions
Good explanation , thanks and keep up the good work !!!!!
Clear explanation ty bro...
I appreciate that you covered immutability. A lot of lessons on this subject don't discuss this, which is a problematic oversight.
Thank you so much, please keep making such video.
Thanks for the explanation. It is easy to understand.
How to make reusable component in angular ? Kindly make video bro.... thanks advance . Videos simply super
Thank you Man, Perfect than many articles.
Thanks very nicely explained
Keep the good Work. You are an amazing man.
Thanks for video, I am Passing for one problem in my job. The data update only if I to click on the screen or to put one event click()… I am go to test this…
Good Video.Thank you.
Thanks. it is a good article
But splice will change the string? Is that means it is changed? Mutable?
The slice function returns with a new string and does not modify the original one. So if you do not save the result of the slice operation in a new var, then the result is lost. The reason you see "example" after the slice is because you are printing the original one, you did not save the result in a new var. Although strings are indeed inmutable, this is not a good reasoning.
Thanks for commenting. Here I was trying to show, no string method operates on actual string being immutable, rather it returns a new string.
this change detection strategy works upon @Input properties only or normal properties also??
question - should i use onPush in every component in my app which has an @input?
or only in components with long lists of component (that can hurt my performance)
thanks!
How about when dealing with strings then? Consider passing a string , seems this concept wont work with immutable.. isn't it ?
Thanks... It was really nice
Thanks Saikat. This video help me a lots to understand change detection methodology but i have two questions in my mind:
1).changeDetectionStrategy.onpush will only work when reference of object changed then What does the difference make mutable or immutable objects.
2). Why should we use detect or detach method of changeDectorRef ? changeDetectionStrategy.onpush will work as same, in your video if we want to detach changes then we can use changeDetectionStrategy.default and if want to detect than we can use changeDetectionStrategy.onpush . Can you please help to understand we should use changeDectorRef.
For #1 a mutable object is one where its state can be changed and still point to the same reference, while an immutable is an object which cannot change its state. To 'change' it, It requires you to create a whole new object with the changes and reassign it back. Mutable means 'capable of change', while 'immutable' means 'not susceptible to change'. You can think of this 'clone and reassign' process for immutable objects as a sort of 'push'. Hence 'changeDetectionStrategy.onpush'.
For #2 I believe the changeDetectorRef allows fine grained control of when these 'change processing' features happen within your code.
nicely cleared
Hi, nice work! Do you know if there is a way I can detach change detector and centralize detectChanges into an event for a child component? I only got it calling detectChanges every place I needed it.
Loved it!! Learnt something..Subscribed :)
Thanks
Yesterday in interview asked this question but I didn't know this
starts at 3:41
it"s nice
U can change string with splice
Splice changes the string in place 1:46
splice is Array function
Saikat's Tutorial sorry my bad
strings are mutable, use splice.
Hello send me the link code thanks
github.com/mysupermate/demoApp