Services and Self-Recomputing Helpers in Ember 2.0

added by bpwndaddy
9/23/2015 3:42:03 PM

649 Views

Before Ember services and advanced API for HTMLBars helpers were introduced, it was not easy to manage the global application state. By global state I mean the data essential for the most of applications out there - such as the current language or the current user info. Whenever this data changes every part of the UI needs to be updated to reflect the change. Previously, the easiest way to do this was the a reload of the current page. Of course, this was a bad, not user-friendly approach but one had very few other options. For example, users of the popular ember-i18n project had the following problems: ember-i18n didn't support bindings on the translations (till the version 3.1.1). ember-i18n didn't load translations so one had to do this on his/her one. Therefore, many people fetched translations in application initializers. Another possibility to apply global changes was to use Route::refresh method. If you loaded translations in the model/beforeModel hooks, it was almost a perfect solution. But still the data that was entered on the page would be lost and the overall user experience was not great. Ember services and self-recomputing helpers were introduced to overcome the problem.


0 comments