- Debuggability - LocalWorkflowVirtualMachine provides linear stack trace
- Persistable - Allows to persist runtime state, and restore in future
- Traceability - Allow
interfaceContext{readonlyappName: string;}interfacePersonContext{name: string;age: number;}classPersonRenderActivityextendsActivity<PersonContext&Context>{protectedonExecute(cancellationToken: CancellationToken,context: PersonContext&Context): void|Promise<void>{console.log(`${context.appName} The ${context.name} is ${context.age} years old.`);}}constworkflow=newContextActivity<Context,PersonContext>({initContext: {name: "Noname",age: 42},child: newWhileActivity({condition: newCodeActivity((ctx)=>{console.log("Checking condition in CodeActivity");ctx.age++;if(ctx.age>45){ctx[WhileActivity.Done]();}}),child: newSequenceActivity({children: [newConsoleLogActivity({text: "one"}),newDelayActivity({durationMilliseconds: 100}),newConsoleLogActivity({text: "two"}),newDelayActivity({durationMilliseconds: 200}),newConsoleLogActivity({text: "three"}),newDelayActivity({durationMilliseconds: 300}),newPersonRenderActivity()]})})});console.log("LocalWorkflowRuntime.invoke(activity, context)");constappContext: Context={appName: "example1"};awaitLocalWorkflowRuntime.invoke(dummyCancellationToken,workflow,appContext);Result:
LocalWorkflowRuntime.invoke(activity, context)
Checking condition in CodeActivity
one
two
three
example1 The Noname is 43 years old.
Checking condition in CodeActivity
one
two
three
example1 The Noname is 44 years old.
Checking condition in CodeActivity
one
two
three
example1 The Noname is 45 years old.
Checking condition in CodeActivity
{SHA}ucpU7gua0rlJJsOaFqhVkoib6LI=