I'm building an Ember app that contains all necessary data internally, and doesn't make any writes to a database. I'm currently storing my data in a route as an array of POJOs, but this obviously isn't sustainable once a second page is added and needs access to the same data.
我正在构建一个内部包含所有必要数据的Ember应用程序,并且不会对数据库进行任何写入。我目前正在将数据作为POJO数组存储在路径中,但是一旦添加第二页并且需要访问相同数据,这显然是不可持续的。
Where is the canonical place to store data in a REST-less, no-writing Ember app? Does it still even make sense to use Ember Data for such a thing?
在无REST,无写Ember应用程序中存储数据的规范位置在哪里?将Ember Data用于这样的事情是否仍然有意义?
1 个解决方案
#1
1
It turns out Ember has a services concept!
事实证明,Ember有一个服务理念!
Long lived data can simply live within a service, which you can then use dependency injection to access from anywhere. See this blog post for more details on services and dependency injection: http://www.hutchinson.io/ember-services-and-dependency-injection/
长期存在的数据可以简单地存在于服务中,然后您可以使用依赖注入从任何地方访问。有关服务和依赖注入的更多详细信息,请参阅此博客文章:http://www.hutchinson.io/ember-services-and-dependency-injection/
Credit goes to alexspeller in #emberjs on irc.freenode.net for the answer
感谢irc.freenode.net上#emberjs中的alexspeller获得答案
#1
1
It turns out Ember has a services concept!
事实证明,Ember有一个服务理念!
Long lived data can simply live within a service, which you can then use dependency injection to access from anywhere. See this blog post for more details on services and dependency injection: http://www.hutchinson.io/ember-services-and-dependency-injection/
长期存在的数据可以简单地存在于服务中,然后您可以使用依赖注入从任何地方访问。有关服务和依赖注入的更多详细信息,请参阅此博客文章:http://www.hutchinson.io/ember-services-and-dependency-injection/
Credit goes to alexspeller in #emberjs on irc.freenode.net for the answer
感谢irc.freenode.net上#emberjs中的alexspeller获得答案