angular/watchtower.js

Docs

Closed this issue · 2 comments

Hello,

At the risk of making a fool of myself, I have to ask: how would I use watchtower.js? The project looks great, and I'm perfectly clear about the concept behind it. Yet, how to actually use the lib is not clear atm.

That's a great question @alexduloz, it actually takes a bit of work to use it on its own. The primary abstraction layer is the abstract syntax trees, in conjunction with the DirtyCheckingChangeDetector classes (for the time being, although perhaps we'll have some other versions of these classes later on).

To give a very simple example, you can look at the parse method implemented in one of the tests: https://github.com/angular/watchtower.js/blob/master/test/watchgroup.spec.js#L26-L32

This function translates a string (basically an angular expression that could be $scope.$watched() in AngularJS) into an AST, which is understood by the change detector.

To have a more complete look at how this could be used, take a look at Angular.dart's Scope implementation. Basically, the library is primarily intended for Angular 2.0's use, but hopefully the abstraction will separate it enough that people might find it useful for other uses independent from Angular, as well.

I would very much like to provide a solid API so that people have an easier time using this independently from angular, but we have a ways to go before it's really that simple unfortunately. But documenting how the API can be used is definitely on the TODO list

Many thanks!

:)