简体   繁体   English

如何在Ember.js中定义并发状态?

[英]How to define concurrent states in Ember.js?

I want to define concurrent states in Ember.js, but the lack of documentation makes it hard to figure out how. 我想在Ember.js中定义并发状态,但是缺少文档使得很难弄清楚如何做到。

You can define mutually exclusive states (system is either in foo or bar ) like so: 您可以这样定义互斥状态(system在foobar ):

App.stateManager = Ember.StateManager.create({
    foo: Ember.State.create({
        //...
    }),
    bar: Ember.State.create({
        //...
    })  
});

EDIT: Response to ud3323 编辑:对ud3323的回应

Isn't the following concurrent states? 下列并发状态不是吗?

App.stateManager = Ember.StateManager.create({
    foo_baz: Ember.State.create({
        foo: Ember.State.create({
           // ...
        }),
        baz: Ember.State.create({
           // ...
        })
    }),
    bar: Ember.State.create({
        //...
    })  
});

But how do you define concurrent states such that, for example, when the system is in foo state, it is also in baz state. 但是如何定义并发状态,例如,当系统处于foo状态时,它也处于baz状态。

For concurrent states you need to use the statechart add-on . 对于并发状态,您需要使用statechart附加组件 Concurrency is not implemented into enber-states as of yet... 到目前为止,并发还没有实现为enber状态。

edit 编辑

Concurrent states === orthogonal regions (in the world of uml state machine design) 并发状态===正交区域(在uml状态机设计领域)

Sorry for not making that clear. 抱歉,不清楚。

Take a look at this Pull request. 看一下这个Pull请求。 It also ties in the routing package as well. 它还与路由包相关。 https://github.com/emberjs-addons/sproutcore-statechart/pull/16#issuecomment-3747310 https://github.com/emberjs-addons/sproutcore-statechart/pull/16#issuecomment-3747310

DominikGuzei also created a sample application showing how it is used. DominikGuzei还创建了一个示例应用程序,显示了如何使用它。 I found it helpful to understand the current (Always chainging) relationship between emberjs and the addons. 我发现了解emberjs和插件之间的当前(始终链接)关系很有帮助。 https://github.com/DominikGuzei/ember-routing-statechart-example https://github.com/DominikGuzei/ember-routing-statechart-example

You can use: Stativus and get full statechart functionality in emberjs right now. 您可以使用: Stativus并立即在emberjs中获得完整的statechart功能。 It is a complete re-write of the old SC statecharts without any of the SC cruft. 这是对旧SC状态图的完全重写,而没有任何SC问题。 (gzipped <3k) (压缩后<3k)

Its more full featured and designed to work with any framework. 它的功能更全,旨在与任何框架一起使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM