Monday, October 14, 2013

Reflective Interceptor, Monitor in Dart (Part 1)

In GUI, persistent data programming, the interceptor for the field access is fundamental.
It can enhance the field access with additional behaviors.
It may trigger another action, or keep recording of some internal changes.
But these behaviors should be irrelevant for the caller of these getter/setter.

These things has been implemented as part of general AOP type injection mechanism like CGlib, asm etc, but these approach would not be possible in Dart,  and overkill for this limited range of interception (getter/setter).

Dart introduced @observable Observable mixin, but Observable class seems not general purpose class, but restricted to polymer html file.

So it is interesting to find an alternative way to support similar idea in more general setting,and apply it to my web-framework, gui-components library.

For this purpose, I created the Monitor class. for the name of the field annotation  to be monitored by Monitor class is 'Monitored'. This Monitor class can be used with mixin as well as subclassing, so any class can be changed to a Monitor class easily.

No comments:

Post a Comment