'xState: dynamic target

I'm very new to xState and wonder how I can use my context to specify a target for another state?

In pseudo-code:

...
my_state1: {
  entry: assign({ my_var: (context)=> 'my_state3' }),
  always: 'my_state2'
},
my_state2: {
  always: (context) => context.my_var
},
my_state3: {
  entry: (context)=>{ console.log("Success!")}
}
...

Is this possible at all or am I just trying to achieve something that is impossible or unintentional usage?

A second question is: Assume I have two state machines. machine1 and machine2.

Is it possible for i.e. machine2 to "call" machine1 in several states and "return back" to the "caller".

Sorry if the questions are silly, I'm all new to this.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source