zettajs/zetta

Allow dynamic addition of transitions and monitored properties

Opened this issue · 1 comments

The standard way to define transitions and monitored properties is to hardcode their specification in a device sub-class in init. This is fine if all transitions and properties are known in advance, but creates a hurdle when creating devices dynamically at run time. See https://groups.google.com/forum/#!topic/zetta-discuss/XPVzd0gLnSE for discussion.

Instead of passing the 'config' object to the sub-class, propose the addition of methods which allow appending entries before init() finishes. Something like:

config.whenAppend(state, transitionFunction);
config.monitorAppend(propertyName);

If it is blocking you before we make any decisions and do the work you may want to check out the implementation of the device_config https://github.com/zettajs/zetta-device/blob/master/device_config.js

You can just modify the underlying config.allowed, not ideal i know but it can work.