Actyx / machines

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

allow adding additional tags when emitting certain events

rkuhn opened this issue · comments

This is often attached to the event type, i.e. should be part of the event design DSL. We need to investigate whether this also is needed in the command design DSL.

Is this tag arbitrary relative to command-type and time?

// without tag
state.commands?.commandName()

// with tag
state.taggedCommands?.(...arbitraryTagsHere).commandName()

In those cases I’m immediately aware of the additional tags are fixed to certain event types, so in most cases I’d think that adding it to the event designer should be more intuitive and less error-prone. Your proposal looks good for the more flexible case, but I’m not yet sure whether we need that from the beginning (that being said: we could also make it state.commands?.withTags(tags).commandName()).

Namespace problem always irks me. I'd add _withTags and prevent commandName to be prefixed with _.

Also if that's the case, we can use context to add tags.

return context.addTags([...tags]).emit([...events])

Ah yes, doing it inside the command handler is much better!

Ok. This is good. We have 2 options that work for us and what is added will depend on what the user will need.
I'd say, at this time, I'll try to prohibit CommandName that starts with _ to reserve this for future features.

Slipped in the constraint in: