What is the best way ( performance wise ) to animate numbers? [closed] - angularjs

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
In my angular.js app i'm using this directive:
https://github.com/sparkalow/angular-count-to
Which works great on the web.
When i compile it for phonegap, it's really really slow.
But what other way i have to animate a number from 0 to 200 (for example), in two secods, without hurting the performance of my app?

The directive uses $timeout, as is the suggested way to get setTimeout functionality in Angular. It's likely doing this for one of the following reasons, though there are others too:
Easy to inject a mock for testing
Assumes that each step should allow other components to update
It's the "Angular Way"
I don't believe #2 is actually a big concern since it doesn't expose the value or update anything on the scope anyway, and does standard HTML textContent manipulation.
Regardless, the point is that $timeout does a setTimeout as well as a $digest (allowing Angular to update other components). The extra digest cycles are likely the slow part, and every Angular developer should read up on them as they're central to Angular's design (hint: go read up on these now). As such, taking the original library, replacing the $timeout with a setTimeout call (and, optionally, a manual digest trigger when it finishes, in the if (step >= steps) block) should speed it up.
Be careful about these sorts of changes, though - $timeout is typically the correct way to go.

Related

Why Angular(2~5) is way faster than AngularJS [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
We all know AngularJS builds a digest loop when it comes to change detection , which proves to be less productive than Angular.
I want to know
How Angular works to get around this performance issue?
Does Angular also have a digest loop similar mechanism? if not , how does it know when a change could happen and need to perform change detection?
I know Angular boasts some features such as zone.js monkeypatch , unidirectional component tree, change detection strategy, RXJS ,immutableJS,etc.. either of which partly or directly drive Angular renders UI faster at the time a change happens. I'm not able to understand how Angular eventually gets faster by using these techniques together and properly?
Table that summarizes the major differences between Angular and AngularJS Change Detection.
To Explore more on this
Change Detection Differences between Angular and AngularJS
Change Detection Reinvented Victor Savkin
Angular’s $digest is reborn in the newer version of Angular
The Angular 2 Compiler Tobias Bosch
The Angular Compiler 4.0 - TOBIAS BOSCH.

what are the major architecture changes in Angular 2 [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am new to angular 2 and SO as well. I would like to know the major architecture changes in Angular2 compared to Angular. There used to be $apply, $digest, $evalAsync and so much more, why was so many changes made in Angular.
From what I understood, the performance was the major issue which has been achieved in Angular2. It's more lightweight and all.
Can someone please shed some light on this. A brief answer would be of great help, just for a jump start.
Thanks in advance
There is a nice article in the docs of Angular 2 that may help you to get a good understanding of its building blocks: https://angular.io/docs/ts/latest/guide/architecture.html
$apply, $digest, $evalAsync does not exist anymore since Angular 2 has no digest cycle anymore.
An Angular 2 application can be pictured as a directed graph of components.
If you come from AngularJS you also can make your components run with Angular 2: https://angular.io/docs/ts/latest/guide/upgrade.html
There you can read really good explanation, how angular2 change detector works:
http://blog.thoughtram.io/angular/2016/02/22/angular-2-change-detection-explained.html
And what in general are zones:
http://blog.thoughtram.io/angular/2016/01/22/understanding-zones.html
http://blog.thoughtram.io/angular/2016/02/01/zones-in-angular-2.html
Here in brief about change detection:
How does optimised data binding mechanism work in Angular2
This is really essential knowledge if you want to create fast apps.

Should I not use Angular 2 Alpha in small-scale production projects? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I get it: the API is going to change, possibly in dramatic ways.
However, I make small apps for less than 10 customers each. I'm thinking that I can:
choose a specific version and stick with it
make lots of tests to check for compatibility with new releases
Also, given the projects are small, there's very little code to update when needed.
I realize that the Angular team is communicating the general readiness of their code in terms of availability for adoption from the general developer user-base.
I hear things like:
"Should You Use Angular 2.0 or 1.x?" =>
"The executive summary: There’s no Angular 2 to use, so Angular 1 is still the way to go."
And then I see videos showing how to use it. And I think to myself: with the above strategy of choosing a specific version & sticking with it + doing very careful updates to new releases, I don't see a very compelling reason not to. I mean, the only thing not to do would be not to go complaining to Angular whenever their changes inevitably break my code; it's expected. I'd be disappointed if it didn't break between now & then. That's part of the fun. Fix it and move on.
Concerns:
Security: the only real concern that gives me pause is that some security issue might be in play. But then, that's almost always the case. After all, it is the world of cyber insecurity.
Angular team can still make major changes in syntax and behaviour.
You can just try to use similiar approach with Angular 1.x, especially they introduced .component in Angular 1.5.
So just work with directives and components, after Angular 2.0 release migration should be fairly easy.

Are there any features that ReactJS possess, while AngularJS lacks? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I was playing with ReactJS for a bit, and given a bit of prior exposure to AngularJS, and the way things are done in the latter, I had a hard time to get used to the syntax and the 'flow' of React.
So I had the above-mentioned question, plus: are there scenarios when ReactJS should be preferred to AngularJS?
Could anyone point out what can be done [easier/better/more efficiently] in React rather than in Angular, and other way around.
It's actually the opposite. Angular has a lot of features, apis, configuration options, etc. React tries to be much simpler and let you choose how your application is structured. Controllers, directives, and templates are reduced to just components. Services are just plain JavaScript, there's nothing React specific about it. Things like $q and $timeout don't exist because there's no digress (use anything you like for those).
You use React in your application, vs making your application in angular.
ReactJS uses the concept of virtual DOM which speeds up the rendering of the app.
Watch Pete Hunt's excellent video on Virtual Dom here:
https://www.youtube.com/watch?v=-DX3vJiqxm4
The syntax might be very unconventional but the same thing can be said about Angular's concept of Directives, services, controllers, etc. It just takes time to get used to, but once you feel comfortable, you'll find that thinking in ReactJS really makes sense.

AngularJS best approach: data driven or event driven? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
AngularJS is famous of the '3d': data binding, dependency injection and directives. As data binding is such a nature of angularJS application, I always assume data-driven is the best approach when making decision on how the app works.
For example, if I want to respond to some property updates, I will $watch on that property and write call back functions for it. And if I can use angularJS properly, there is no $apply required and the two way data binding will automatically do the magic with the great digest cycles.
However, in jQuery or many other JavaScript libraries, event-driven seems to be so common that people always think this is how client side should work. Event-driven approach in angularJS, on the other hand, means I need to $emit or $broadcast events across directives/controllers to throw events here and there. This is somehow different to the data-driven approach.
My idea is event-driven makes the whole application hard to debug, understand and maintain. The only reason I use it is because it's easy to pass data across scopes, when the nested scopes themselves are too complicated to do so.
Any idea on this? When should we stick to data-driven and when should we use event driven? What is the best approach in general?

Resources