目前我正在使用基于python的flex4+robotlegs+as3signals+google应用程序引擎构建一个相当大的应用程序。
1)好吧,问题是我发现自己从视图到调解器以及从调解器到上下文重新分配相同的信号。
2)另一个问题是我正在执行来自中介者的信号命令,这些中介者仅在模型上运行 1 个方法。
请记住,使用 Flex 4 时,皮肤可能与业务逻辑分离。
所以我有一个皮肤、该皮肤的一个组件 (SkinnableComponent) 和一个模型。这是我的新方法:组件在皮肤上监听。该组件具有强类型模型对象(注入)并直接调用方法。该组件侦听要调度的模型信号。这就是组件的全部内容。中介者在组件中进行转换。并且该命令没有被使用。
现在的问题是:
不要将视图(在我的例子中我称之为组件)映射到中介器,只需映射没有附加中介器的组件,因为未使用中介器。然后允许组件使用 [Inject] 元标记。
这就是我所需要的,关于如何实现它有什么想法吗?
当然,我很高兴听到您的意见和批评,它总是有助于改进;)
感谢您的宝贵时间! ;)
代码:
[皮肤]
调度由用户引起的事件
[Component] 就像一个中介者,但有很大不同,因为它扩展了 SkinnableComponent。
捕捉皮肤事件。有一个强类型模型。然后调用模型上的直接方法。听模型。当模型调度事件时,组件的状态会发生变化。
...
[Inject]
public var accountModel:AccountModel;
[Inject]
public var xxxModel:XxxModel;
// then the component run methods on it and listen on it. easy and no complications.
[模型]
他们什么都不知道。只需发送事件或信号。
Currently I'm building quite a large app with flex4+robotlegs+as3signals+google app engine based on python.
1) Well the problem is that I'm finding myself redipsatching the same signals from the view to mediator and from mediator to context.
2) The other problem is that I'm executing commands for signals from mediators that just run 1 method on the model.
Remember that working with flex 4, the skin might be separed from the business logic.
So I have a skin, a component (SkinnableComponent) for that skin and a model. That is my new approach: the component listen on skin. The component has strong typed model objects (injected) and call methods directly. The component listen for model signals to dispatch. That's all for the components. The mediators are converted in the component. And the command is not used.
Now the problem is:
Instead of mapping views (in my case I call them components) to mediators, just map the component with no mediator attached, as is not used. Then allow the component to use the [Inject] metatag.
Just this is what I need, any idea on how to implement it?
And of course, I would be glad to hear your oppinion and critcize on it, it always help to improve ;)
thanks for your time! ;)
Codes:
[Skin]
dispatches the events caused by the user
[Component] is like a mediator, but quite different as it extends the SkinnableComponent.
catch skins events. has a strong typed model. then call direct methods on the model. listen on models. when models dispatch an event the state of component changes.
...
[Inject]
public var accountModel:AccountModel;
[Inject]
public var xxxModel:XxxModel;
// then the component run methods on it and listen on it. easy and no complications.
[Model]
they don't know about nothing. just dispatch events or signals.
发布评论
评论(2)
您在这里为自己节省了一个课程,但现在您在视图组件上添加了额外的知识和责任。当然,这会起作用,您可以查看我关于使用 带有 Robotlegs 的演示模型。我不会像你描述的那样推荐它。如果我要以这种方式工作,那肯定是和产品经理一起工作。
You're saving yourself a class here, but you are now adding the extra knowledge and responsibility on your view component. This will work, of course, and you might check out my article on using Presentation Models with Robotlegs. I wouldn't recommend it as you describe. If I was going to work this way it would definitely be with a PM.
您可能想看看 Adobe TV 文章 /pwalczyszyn" rel="nofollow">Piotr Walczyszyn
他对许多 DI AS3/Flex 框架(包括 Robotlegs)进行了比较。
You might want to have a look at this Adobe TV article by Piotr Walczyszyn
He does a comparison of many DI AS3/Flex frameworks including Robotlegs.