xstate-tools
xstate-tools copied to clipboard
Rename machine event keys when renaming the model's events
When renaming events on a model (Rename Symbol
/ F2), VSCode doesn't rename the corresponding event keys in the machine defintion.
This would be a nice quality-of-life improvement when using createModel
.
Example
import {createMachine} from 'xstate'
import {createModel} from 'xstate/lib/model'
const model = createModel(
{
name: 'Matt',
},
{
events: {
nameChange: (name: string) => ({name}),
},
},
)
const machine = model.createMachine(
{
on: {
nameChange: {actions: 'setName'},
},
},
{
actions: {
setName: model.assign(
{
name: (_context, event) => event.name,
},
'nameChange',
),
},
},
)
Using the VSCode Rename Symbol
feature on nameChange
inside the model definition should also rename the event key inside the on
definition and in the second argument to model.assign
.
Tasty, that would be great.
Surprised that this doesn't work, while "go to definition" does!
cc. @Andarist is this possible?