mercredi 27 septembre 2017

How can I model singletons without an id in ember?

I am new to ember and am trying to migrate an existing application, and would like to know what the recommendation is for modeling a single object that will be reused in multiple components on every page. ie: As part of the initial load, I would like to perform a GET request against a URL like 'http://ift.tt/2wkjoNb' and get an object back like:

  {
    name: "Users Name"
    email: "user@email.com",
    profileImg: "http://ift.tt/2fB0ONE"
    ... snip ...
  }

This object will then be used in components for menus, toolbars, and a form for updating it via a post to the same URL.

What is the best way to model this workflow in ember? Given that this is an incidental object and not the focus of most routes, it does not seem to make sense to specify it as the model of them. Also, does ember data handle cases where a model is a singleton and does not have an ID, or would I need to use something like Ember.$.ajax ?




Aucun commentaire:

Enregistrer un commentaire