Skip to content

Variable number of parallel states, how to re-use actions? #1315

Discussion options

You must be logged in to vote

Answering my own question. I had read this line from the actions documentation which states Each action object has two properties (and others, that you can specify) but it didn't dawn on me that this means I can put arbitrary properties which can be read from the exec's meta argument. This solves my issue. I'll leave this here instead of deleting the question in case it can be of help to someone else.

Example solution:

...
  invoke: {
    src: 'service1',
    onDone: {
      actions: {
       type: 'appendDataService,
       serviceName: 'service1',
    }
  }
...
{
  actions: {
    appendDataService: (context, event, meta) => {
      context[meta.action.serviceName] = event.data;
    }
  …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mattpeskett
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant