State Change Trigger pattern
When an svc_expr
service has states, the notify operations on the
service can be conditionalized to trigger on state changes.
In the example in Table 1, a notify
operation is triggered as soon as the Count
state variable exceeds 5.
Example | Description |
---|---|
<mix name="Mix"> <service name="Expr" provision="expr"> <prop name="expr.state" Count="NewCount"/> </service> <notify name="myNotify" service="Sequencer" clients="Expr" fields="TRIGGER"> <prop name="expr.state" Count="OldCount"/> <prop name="expr.src" content-type="text/x-erlang"><![CDATA[ Count > 5. ]]></prop> </notify> </mix> Note: Do not manually type the
<![CDATA...]]> delimiters. The Editor
automatically renders text content as XML CDATA sections. |
The myNotify operation specifies the Expr
service as a client. The Expr service has Count as a
state variable.When the Note: The old value of the
Count state variable is available in the
OldCount variable which can be used by any expression in the
expressions list.If the final expression value is If the
value of the final expression is any value other than The If more than one variable is specified in the
|