Skip to content

Actions & guards, dependencies and sequence #1359

Answered by Perlkonig
Perlkonig asked this question in General
Discussion options

You must be logged in to vote

I feel bad that this has completely gone off from the original question, Thank you again for your time.

So it now appears to be working as expected. Since my context is a class, I had to mark the class as "immerable" first. Then I was able to delete the previous action that was defined in the machine definition and replace it with a constant assigner function defined outside of the machine, as follows:

import { assign } from '@xstate/immer';

const setSearchStage = assign<MyContext, MyEvents>((context, event) => {
    const data = {};
    /* A bunch of logic to populate `data` */
    context.data = data;
});

/* Start of machine definition */
            searching: {
                initial

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
6 replies
@mattpocock
Comment options

@Perlkonig
Comment options

@mattpocock
Comment options

@mattpocock
Comment options

@Perlkonig
Comment options

Comment options

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