1

我正在编写一个简单的软件作为服务,例如应用程序,每个客户为特定组件定义一组配置。然后在运行时我需要基于这个配置构建一系列模型。

我的问题是我应该何时查找配置并构建动态 ember 对象数组来表示这些模型?

目前我正在 ApplicationRoute 本身的 setupControllers 函数中玩这个(因为它在加载应用程序时只加载了 1x ,然后我将随时拥有模型数组,而不是稍后及时等待它们.)

这组配置是最小的,从这个方法中获得的性能对于这个例子来说是值得的。但这是加载这些/创建动态模型的正确组件吗?

4

1 回答 1

1

My question is when should I lookup the configuration and build the array of dynamic ember objects to represent these models?

It depends of course ;-)

  • If you need ember to be in a loading state while the lookup happens, then setupControllers is too late. In that case consider using the model hook instead.
  • Do you need to do all of this configuration upfront? If not maybe push it down to setupControllers callback on a subroute.

But is this the right component to load these up / create dynamic models?

Yes - in this case I'd say setupControllers on application route is a good choice.

于 2013-02-04T21:55:13.720 回答