当前位置: 首页 > news >正文

任县网站建设网络公司网赌代理

任县网站建设网络公司,网赌代理,东莞效果好的网站建设,罗湖高端网站设计XState 做为一个非常好用的前端状态机库#xff0c;但官网文档却只有英文版#xff0c;为了阅读体验#xff0c;我这里翻译了中文版。 仓库地址#xff1a;https://github.com/lecepin/xstate-docs-cn文档地址#xff1a;https://lecepin.github.io/xstate-docs-cn/zh 由…XState 做为一个非常好用的前端状态机库但官网文档却只有英文版为了阅读体验我这里翻译了中文版。 仓库地址https://github.com/lecepin/xstate-docs-cn文档地址https://lecepin.github.io/xstate-docs-cn/zh 由于本人水平有限加上翻译周期较短出现错误在所难免欢迎广大读者批评指正。 JavaScript 状态机和状态图 用于现代 Web 的 JavaScript 和 TypeScript 的 有限状态机 和 状态图 。 还不了解状态机和状态图 阅读我们的介绍。 遵守 SCXML 规范 在 Stately Discord Community 和我们交流 包 xstate - 有限状态机和状态图核心库 解释器 xstate/fsm - 最小有限状态机库 xstate/graph - XState 的图遍历实用工具包⚛️ xstate/react - 在 React 应用中使用 XState 的 React Hooks 和实用工具包 xstate/vue - 用于在 Vue 应用中使用 XState 的 Vue 组合函数和实用工具包 xstate/svelte - 用于在 Svelte 应用中使用 XState 的 Svelte 实用工具包✅ xstate/test - 基于模型测试的实用工具包使用 XState xstate/inspect - XState 的检查实用工具包 模板 首先在 CodeSandbox 上创建这些模板之一 XState Template - 没有框架XState TypeScript Template - 没有框架XState React TemplateXState React TypeScript TemplateXState Vue TemplateXState Vue 3 TemplateXState Svelte Template 超级快速上手 npm install xstateimport { createMachine, interpret } from xstate;// 无状态的状态机定义 // machine.transition(...) 是解释器使用的纯函数。 const toggleMachine createMachine({id: toggle,initial: inactive,states: {inactive: {on: {TOGGLE: { target: active }}},active: {on: {TOGGLE: { target: inactive }}}} });// 具有内部状态的状态机实例 const toggleService interpret(toggleMachine).onTransition((state) console.log(state.value)).start(); // inactivetoggleService.send({ type: TOGGLE }); // activetoggleService.send({ type: TOGGLE }); // inactivePromise 示例 在 stately.ai/viz 上查看可视化 import { createMachine, interpret, assign } from xstate;const fetchMachine createMachine({id: Dog API,initial: idle,context: {dog: null},states: {idle: {on: {FETCH: { target: loading }}},loading: {invoke: {id: fetchDog,src: (context, event) fetch(https://dog.ceo/api/breeds/image/random).then((data) data.json()),onDone: {target: resolved,actions: assign({dog: (_, event) event.data})},onError: {target: rejected}},on: {CANCEL: { target: idle }}},rejected: {on: {FETCH: { target: loading }}},resolved: {type: final}} });const dogService interpret(fetchMachine).onTransition((state) console.log(state.value)).start();dogService.send({ type: FETCH });可视化工具为什么?有限状态机分层嵌套状态机并行状态机历史状态 可视化工具 在 XState Viz 中可视化、模拟和共享你的状态图 为什么? 状态图是一种用于对有状态的交互式系统进行建模的方式。从单个组件到整个应用程序逻辑这对于以声明方式描述应用的 行为 非常有用。 阅读 幻灯片 ( 视频) 或查看这些资源以了解有限状态机和状态图在 UI 中的重要性 状态图 - 一个复杂系统的可视化表现 by David Harel状态图的世界 by Erik Mogensen纯 UI by Guillermo Rauch纯 UI 控制 by Adam SoloveSpectrum - 状态图社区 (对于 XState 特定问题请使用 GitHub 讨论) 有限状态机 import { createMachine } from xstate;const lightMachine createMachine({id: light,initial: green,states: {green: {on: {TIMER: { target: yellow }}},yellow: {on: {TIMER: { target: red }}},red: {on: {TIMER: { target: green }}}} });const currentState green;const nextState lightMachine.transition(currentState, { type: TIMER }).value;// yellow分层嵌套状态机 import { createMachine } from xstate;const pedestrianStates {initial: walk,states: {walk: {on: {PED_TIMER: { target: wait }}},wait: {on: {PED_TIMER: { target: stop }}},stop: {}} };const lightMachine createMachine({id: light,initial: green,states: {green: {on: {TIMER: { target: yellow }}},yellow: {on: {TIMER: { target: red }}},red: {on: {TIMER: { target: green }},...pedestrianStates}} });const currentState yellow;const nextState lightMachine.transition(currentState, { type: TIMER }).value; // { // red: walk // }lightMachine.transition(red.walk, { type: PED_TIMER }).value; // { // red: wait // }分层状态的对象符号 // ... const waitState lightMachine.transition({ red: walk },{ type: PED_TIMER } ).value;// { red: wait }lightMachine.transition(waitState, { type: PED_TIMER }).value;// { red: stop }lightMachine.transition({ red: stop }, { type: TIMER }).value;// green并行状态机 import { createMachine } from xstate;const wordMachine createMachine({id: word,type: parallel,states: {bold: {initial: off,states: {on: {on: {TOGGLE_BOLD: { target: off }}},off: {on: {TOGGLE_BOLD: { target: on }}}}},underline: {initial: off,states: {on: {on: {TOGGLE_UNDERLINE: { target: off }}},off: {on: {TOGGLE_UNDERLINE: { target: on }}}}},italics: {initial: off,states: {on: {on: {TOGGLE_ITALICS: { target: off }}},off: {on: {TOGGLE_ITALICS: { target: on }}}}},list: {initial: none,states: {none: {on: {BULLETS: { target: bullets },NUMBERS: { target: numbers }}},bullets: {on: {NONE: { target: none },NUMBERS: { target: numbers }}},numbers: {on: {BULLETS: { target: bullets },NONE: { target: none }}}}}} });const boldState wordMachine.transition(bold.off, { type: TOGGLE_BOLD }).value;// { // bold: on, // italics: off, // underline: off, // list: none // }const nextState wordMachine.transition({bold: off,italics: off,underline: on,list: bullets},{ type: TOGGLE_ITALICS } ).value;// { // bold: off, // italics: on, // underline: on, // list: bullets // }历史状态 import { createMachine } from xstate;const paymentMachine createMachine({id: payment,initial: method,states: {method: {initial: cash,states: {cash: {on: {SWITCH_CHECK: { target: check }}},check: {on: {SWITCH_CASH: { target: cash }}},hist: { type: history }},on: {NEXT: { target: review }}},review: {on: {PREVIOUS: { target: method.hist }}}} });const checkState paymentMachine.transition(method.cash, {type: SWITCH_CHECK });// State { // value: { method: check }, // history: State { ... } // }const reviewState paymentMachine.transition(checkState, { type: NEXT });// State { // value: review, // history: State { ... } // }const previousState paymentMachine.transition(reviewState, {type: PREVIOUS }).value;// { method: check }
http://wiki.neutronadmin.com/news/358459/

相关文章:

  • 网站被黑客入侵怎么办工作时做网站使用软件
  • linux做网站优势建网站公司哪里好
  • WordPress主题站外贸开发产品网站建设
  • 淘宝客网站模板购买手机排行榜2021前十名性价比
  • 微信支付 网站备案如何设计一个实验方案
  • 网站建设方案选择实现方式做微信的网站叫什么米
  • 大庆城市建设投资网站怎么做国际货运代理外贸网站
  • wordpress建设的网站软件开发培训难学吗
  • 网站的建设参考文献西安网站制作机构
  • 环保网站建设模板免费下载天元建设集团有限公司申请破产
  • 莱芜网站优化怎么做兰州网站建设设计
  • 各大网站图片用ai怎么做网站
  • 银川网站设计建设做运营必知网站
  • 桥的设计网站建设做app网站的公司名称
  • 深圳招聘网站如何建设提卡网站
  • 怎么看别人网站在哪里做的外链wordpress 密码失败
  • 网站建设需求方案pdf如何制作视频教程
  • 2008iis 网站 打不开三明建设局网站
  • 黄山市非遗网站策划书申通物流的网站建设
  • 最超值的网站建设wordpress文章摘要
  • wordpress如何从网站登录后台建站及推广
  • 做网站原型图是用什么软件wordpress评论分页
  • 吉首公司网站找谁做南通免费网站建设
  • 网站建设详细报价移动端网站设计制作
  • 做企业网站类型wordpress升级后等待
  • 网站信息内容建设 宣传部门酒店网站建设项目
  • 什么是网站建设与维护赣州做网站找谁
  • 郑州网站优化效果wordpress获取自定义栏目
  • 做一个网站要多少钱wordpress原始密码
  • 51这个网站还有吗哔哩哔哩网页版下载