Skip to content

Commit

Permalink
Deprecate createModel(...)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkpiano committed Sep 18, 2022
1 parent 333f803 commit 771ca1f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/shiny-kangaroos-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'xstate': minor
---

The `createModel(...)` function is now marked as deprecated, as it will be removed in XState version 5. It is recommended to use [Typegen](https://stately.ai/blog/introducing-typescript-typegen-for-xstate) instead.
6 changes: 6 additions & 0 deletions docs/fr/guides/models.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Models

::: warning

The `createModel(...)` function is deprecated and will be removed in XState version 5. It is recommended to use [Typegen](https://stately.ai/blog/introducing-typescript-typegen-for-xstate) instead.

:::

In XState, you can model a machine's `context` and `events` externally by using `createModel(...)`. This provides a convenient way to strongly type `context` and `events`, as well as helpers for event creation, assignment and other implementation details in the future.

Using `createModel(...)` is _completely optional_, and is meant to improve the developer experience. The main reasons for using it are:
Expand Down
6 changes: 6 additions & 0 deletions docs/guides/models.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Models

::: warning

The `createModel(...)` function is deprecated and will be removed in XState version 5. It is recommended to use [Typegen](https://stately.ai/blog/introducing-typescript-typegen-for-xstate) instead.

:::

In XState, you can model a machine's `context` and `events` externally by using `createModel(...)`. This provides a convenient way to strongly type `context` and `events`, as well as helpers for event creation, assignment and other implementation details in the future.

Using `createModel(...)` is _completely optional_, and is meant to improve the developer experience. The main reasons for using it are:
Expand Down
6 changes: 6 additions & 0 deletions docs/zh/guides/models.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# 模型 Models

::: warning

The `createModel(...)` function is deprecated and will be removed in XState version 5. It is recommended to use [Typegen](https://stately.ai/blog/introducing-typescript-typegen-for-xstate) instead.

:::

在 XState 中,你可以使用 `createModel(...)` 在外部对状态机的 `context``events` 进行建模。 这提供了一种强类型`context``events` 的便捷方式,以及未来事件创建、分配和其他实现细节的帮助。

使用 `createModel(...)`_完全可选的_,旨在改善开发人员体验。 使用它的主要原因是:
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import {
ModelCreators
} from './model.types';

/**
* @deprecated Use [Typegen](https://stately.ai/blog/introducing-typescript-typegen-for-xstate) instead.
*/
export function createModel<
TContext,
TEvent extends EventObject,
Expand Down

0 comments on commit 771ca1f

Please sign in to comment.