🍁Use sub chain
In some cases, you may write rules with expressions that are nested many levels.
For example, does the following process seem complicated?
Flow chart
In fact, you use regular expressions to write, pay attention to indentation, and it can be easily read. The above graph can be written as the following regular expression:
<chain name="chain4">
THEN(
A, B,
WHEN(
THEN(C, WHEN(J, K)),
D,
THEN(H, I)
),
SWITCH(X).to(
M,
N,
WHEN(Q, THEN(P, R)).id("w01")
),
Z
);
</chain>
But maybe some people still feel a little complicated.
LiteFlow also supports the definition of sub-chain in the new version of the expression. You can separate and define sub-chain separately, so the above expression can also be written in the following form:
<chain name="mainChain">
THEN(
A, B,
WHEN(chain1, D, chain2),
SWITCH(X).to(M, N, chain3),
z
);
</chain>
<chain name="chain1">
THEN(C, WHEN(J, K));
</chain>
<chain name="chain2">
THEN(H, I);
</chain>
<chain name="chain3">
WHEN(Q, THEN(P, R)).id("w01");
</chain>
Is it much clearer by splitting it into sub-chain?
Help us improve this document (opens new window)
last update: 2022/10/13, 00:02:27