dimanche 16 avril 2017

angular2 after ember2 : computed, DS, route refresh

I'm finishing project on Ember2 and a new project is not far off, on which I want to try Angular2(4 at now). However, after a couple of days of studying it a few questions arose, without answers to which it's difficult to make choice. That's why I'm here.

1) Analogy of computed properties in Angular.

The first thing that is very difficult for me to understand after experience with Ember, is the lack of calculated properties in the Angular components. I added console logs and saw that for the slightest sneeze, Angular starts recalculating all bindings. Surely Angular understands which properties have been changed, so why not make the annotation, which would indicate after changes of which properties the particular binding should be recomputed. For example if name or surname inputs was changed, only in that case 'fullName' getter should be recomputed. On my current project (the banking system) we have several pages with rather complicated logic, I'm afraid to imagine what would happen if ember restarted the calculation of all computed properties as Angular do.

2) The second question is how's difficult to work with data in Angular.

Actually question is 'Is there some instruments to manager data in one storage'? Some time ago I worked with angularjs(the first version) and it was full of pain to manage complex relationships and state of datas manually.

3) Refresh the current route.

How it works in Ember: I have a lifecycle hook named model, in there I pull the data from server and route starts. In the rest of the code, I have computed properties dependent on these data, then the computed properties dependent on these computed properties and so on. Thus, updating the model, I update the entire current router. This thing is not used often, usually enough that after a certain action on the server, the result is returned with data that will cover all the changes that have occurred (for example, the balance of the transaction was changed, and the server returned the account's recalculated balance), but there are situations when on the server the large changes has occured, the result of which would be the same as after refreshing the current route. So Ember provide ability to refresh model hook. What should I do in Angular in such case?

Probably I just think "in Ember mode" but I ask you not to give me an absolute analogy, but at least the solution or approach used by Angular




Aucun commentaire:

Enregistrer un commentaire