Skip to content

Commit 587dca5

Browse files
committed
remove async IIFE section
1 parent 450a109 commit 587dca5

File tree

1 file changed

+0
-37
lines changed

1 file changed

+0
-37
lines changed

docs/actors.mdx

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -440,43 +440,6 @@ const machine = createMachine({
440440
});
441441
```
442442

443-
To use `async`/`await`, you may find it more expressive to wrap your code in an [asynchronous immediately invoked function expression (IIFE)](https://developer.mozilla.org/en-US/docs/Glossary/IIFE#execute_an_async_function).
444-
445-
```ts
446-
const machine = createMachine({
447-
initial: 'running',
448-
states: {
449-
running: {
450-
invoke: {
451-
src: fromCallback(({ sendBack }) => {
452-
// highlight-start
453-
(async () => {
454-
try {
455-
const data = await somePromise();
456-
sendBack({ type: 'done', data });
457-
} catch (error) {
458-
sendBack({ type: 'error', data: error });
459-
}
460-
})();
461-
// highlight-end
462-
463-
return () => {
464-
/* cleanup function */
465-
};
466-
})
467-
},
468-
// highlight-start
469-
on: {
470-
error: {
471-
actions: ({ event }) => console.error(event.data)
472-
}
473-
}
474-
// highlight-end
475-
}
476-
}
477-
});
478-
```
479-
480443
## Higher-level actor logic
481444

482445
Higher-level actor logic enhances existing actor logic with additional functionality. For example, you can create actor logic that logs or persists actor state:

0 commit comments

Comments
 (0)