Skip to content

When to use state vs return type in Process framework? #12273

Answered by esttenorio
hansmbakker asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @hansmbakker, return ->OnFunctionResult is recommended when your function only returns the same object type when executed [no conditional logic or complex logic that may need to branch out to different process paths]

Making use of EmitEventAsync allows custom mapping of events from a same function. Example:

if (someCondition)
{
    await context.EmitEventAsync("ConditionSucceded", correctlyGeneratedObject);
} 
else 
{
    await context.EmitEventAsync("ConditionNotMeet", reasonsObjectFailedToBeGenerated);
}

correctlyGeneratedObject and reasonsObjectFailedToBeGenerated can be different object types and yet be emitted by the same function. If using onFunctionResult probably a struct with …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@esttenorio
Comment options

Answer selected by esttenorio
@hansmbakker
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
.NET Issue or Pull requests regarding .NET code
3 participants