Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate createModel(...) #3607

Merged
merged 1 commit into from
Dec 3, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
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