# 目标

¥Goals

# API 目标

¥API Goals

# 选择 XState

¥Choosing XState

如果你正在决定是否应该使用 XState,John Yanarella (opens new window) 很好地总结了他的原因(链接和重点是我的):

¥If you're deciding if you should use XState, John Yanarella (opens new window) summed up his reasons really well (links and emphasis mine):

当我在工作中就是否使用和提倡使用 XState 做出同样的选择时,对我来说最突出的事情是:

¥When I was making that same choice as to whether to use and advocate for the use of XState where I work, the things that stood out for me were:

  1. 致力于了解相关现有技术并根据现有研究论文(Harel 的 关于状态图的原始论文 (opens new window))、书籍(Horrocks 的 "使用状态图构建用户界面" (opens new window))和标准(W3C 的 SCXML (opens new window))为实现提供信息。

    ¥The commitment to understanding the relevant prior art and informing the implementation based on existing research papers (Harel's original paper on statecharts (opens new window)), books (Horrocks' "Constructing the User Interface with Statecharts" (opens new window)), and standards (W3C's SCXML (opens new window)).

我一路上回顾的许多其他库都是止步于实现简单有限状态机的项目。(如果这就是你所需要的 - 也可能是 - 大卫很快指出只需要很少的几行代码就可以完成你自己的工作。)它们的范围被缩短了,因为它们没有解决可以通过状态图克服的后续限制。

¥Many of the other libraries I reviewed along the way are projects that stop at the point of implementing simple finite state machines. (If that's all you need - and it might be - David's been quick to point out how few lines it takes to just roll your own.) Their reach is shortened, since they don't address the subsequent limitations that can be overcome via a statechart.

XState 拥抱 W3C 的 SCXML 规范 (opens new window),站在巨人的肩膀上 - 它受益于该工作组对边缘案例的研究。

¥XState stands on the shoulders of giants by embracing W3C's SCXML spec (opens new window) - it gets the benefit of that working group's research into edge cases.

  1. 这是 "闪亮对象综合症" 的避难所,拥抱本月最新的 "状态管理库" 风格。它忠实地贯彻了 30 多年的形式主义。你最终将最重要的逻辑放入可以随身携带到任何 UI 框架(也可能用于其他语言的其他状态图实现)的东西中。它是一个零依赖库。

    ¥It's a refuge from the "shiny object syndrome" of embracing the latest flavor-of-the-month "state management library". It faithfully implements a 30+ year old formalism. You end up putting your most important logic into something you can take with you to any UI framework (and potentially to other statechart implementations in other languages). It's a zero-dependency library.

前端开发世界是狂野的西部,它可以从其他工程学科多年来已知和使用的东西中学习。

¥The front-end development world is the wild west, and it could stand to learn from what other engineering disciplines have known and employed for years.

  1. 从版本 4 开始,它已经通过了成熟度的关键阈值,特别是考虑到 可视化者 (opens new window) 的引入。这只是它下一步发展的冰山一角,因为它(和 它的社区 (opens new window))引入了利用状态图可视化、分析和测试方式的工具。

    ¥It has passed a critical threshold of maturity as of version 4, particularly given the introduction of the visualizer (opens new window). And that's just the tip of the iceberg of where it could go next, as it (and its community (opens new window)) introduces tooling that takes advantage of how a statechart can be visualized, analyzed, and tested.

  2. 围绕它发展的社区以及它给有限状态机和状态图带来的认识。如果你回顾一下这个 gitter 历史,就会发现有大量研究论文、其他 FSM 和 Statechart 实现等的链接,这些都是 Erik Mogensen (opens new window)statecharts.github.io (opens new window) 收集的。

    ¥The community that is growing around it and the awareness it is bringing to finite state machines and statecharts. If you read back through this gitter history, there's a wealth of links to research papers, other FSM and Statechart implementations, etc. that have been collected by Erik Mogensen (opens new window) over at statecharts.github.io (opens new window).