📜 ⬆️ ⬇️

Angular Light + Object.observe

Angular Light is an independent client MV (C / VM) framework, which is built on the ideas of Angular.js and Knockout.js, and is similar to the simplified Angular.js



Angular Light 0.8 has been released, which includes various improvements and fixes, major changes:
')
1. Support for Object.observe and Array.observe , which can increase the performance of web applications.
Using Object.observe is an optional feature, it can also be enabled for individual Scope (scope of trees). Browsers that do not support Object.observe continue to work through dirty-checking, you also need to know some nuances .

Some spherical tests:
Speed ​​search for changes in scope, jsperf.
The result can be seen in the picture above.

Search for changes in arrays , in this test there are 2000 arrays, each contains 2000 elements, on the first pass there are no changes in arrays, on the second there is a change of 100 arrays. Approximate results on my laptop:
Dirty-checking: 35ms and 65ms
Object.observe: 0.1ms and 1ms

Also for this feature there is a margin for increasing productivity, for example, the “digest” cycle may exclude those scope in which there were no changes, this may improve the performance by an order of magnitude (for tests above).

Although in real applications the overall performance will not be so good. you can't cover everything with Object.observe and some part will work through dity-checking, but for large applications the profit can be noticeable.

2. The ability to isolate Angular Light , this allows you to embed your application into other people's pages without “harm” - there will not be any global variables from the application and the framework on the page.
It is also possible to use different versions of Angular Light on the same page, and create copies of Angular Light if necessary. angularlight.org/tutorial/isolated-alight.html#ru

3. Private directives, controllers and filters.
For each scope (scope of the tree), you can set your own set of directives, make private directives. To do this, in the scope you need to make the $ ns variable and add the necessary directives, controllers, filters. Example jsfiddle.net/lega911/9mfpbrw7

4. Improved performance and memory consumption, increased test coverage, which has nearly 800 checks.

Previous articles:

Source: https://habr.com/ru/post/250589/


All Articles