如何在 Ember.js 中定义并发状态?
我想在 Ember.js 中定义并发状态,但由于缺乏文档,很难弄清楚如何定义。
您可以定义互斥状态(系统位于 foo
或 bar
中),如下所示:
App.stateManager = Ember.StateManager.create({
foo: Ember.State.create({
//...
}),
bar: Ember.State.create({
//...
})
});
编辑:响应 ud3323
下面这不是并发状态吗?
App.stateManager = Ember.StateManager.create({
foo_baz: Ember.State.create({
foo: Ember.State.create({
// ...
}),
baz: Ember.State.create({
// ...
})
}),
bar: Ember.State.create({
//...
})
});
但是,如何定义并发状态,例如,当系统处于 foo
状态时,它也处于 baz
状态。
I want to define concurrent states in Ember.js, but the lack of documentation makes it hard to figure out how.
You can define mutually exclusive states (system is either in foo
or bar
) like so:
App.stateManager = Ember.StateManager.create({
foo: Ember.State.create({
//...
}),
bar: Ember.State.create({
//...
})
});
EDIT: Response to 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于并发状态,您需要使用 statechart 插件。到目前为止,并发还没有实现到 enber 状态中...
编辑
并发状态 === 正交区域(在 uml 状态机设计的世界中)
抱歉没有说清楚。
For concurrent states you need to use the statechart add-on. Concurrency is not implemented into enber-states as of yet...
edit
Concurrent states === orthogonal regions (in the world of uml state machine design)
Sorry for not making that clear.
看看这个 Pull 请求。它还与路由包相关。
https://github.com/emberjs-addons/sproutcore-statechart /pull/16#issuecomment-3747310
DominikGuzei 还创建了一个示例应用程序,展示了如何使用它。我发现了解 emberjs 和插件之间当前(始终链接)的关系很有帮助。
https://github.com/DominikGuzei/ember-routing-statechart-example
Take a look at this Pull request. It also ties in the routing package as well.
https://github.com/emberjs-addons/sproutcore-statechart/pull/16#issuecomment-3747310
DominikGuzei also created a sample application showing how it is used. I found it helpful to understand the current (Always chainging) relationship between emberjs and the addons.
https://github.com/DominikGuzei/ember-routing-statechart-example
您可以使用:Stativus 并立即在 emberjs 中获取完整的状态图功能。它完全重写了旧的 SC 状态图,没有任何 SC 缺陷。 (gzipped <3k)
其功能更全面,旨在与任何框架一起使用。
You can use: Stativus and get full statechart functionality in emberjs right now. It is a complete re-write of the old SC statecharts without any of the SC cruft. (gzipped <3k)
Its more full featured and designed to work with any framework.