Skip to content
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions versioned_docs/version-5/machines.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const feedbackMachine = createMachine(
delays: {
/* ... */
},
}
},
);
```

Expand Down Expand Up @@ -143,6 +143,31 @@ const feedbackActor = interpret(customFeedbackMachine).start();
// logs 'Doing something custom!'
```

:::warningxstate

`machine.provide()` is not imperative but rather returns a new machine that includes the implementation overrides.

:::

Modifying the previous example, if we were to imperatively call `.provide()` on an existing machine, that would not change the machine’s behavior with our implementations.

```ts
// Do NOT do this!
const feedbackMachine = createMachine({...});

feedbackMachine.provide({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assign this to a new machine var and pass to createActor(newMachine)

actions: {
doSomething: () => {
console.log('Doing something custom!');
},
},
});

// This will NOT utilize the provided implementations.
const feedbackActor = interpret(feedbackMachine).start();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be createActor.


```

## Specifying types

You can specify TypeScript types inside the machine config using the `.types` property:
Expand Down Expand Up @@ -246,4 +271,4 @@ const machineWithImpls = machine.provide({
/* ... */
},
});
```
```