AJAX promise without Ember Data

前端 未结 3 922
夕颜
夕颜 2020-12-07 15:00

I have decided to not use ember-data as it\'s not production ready and still changing. My app only needs to make a few ajax requests anyway so it shouldn\'t make too big of

3条回答
  •  盖世英雄少女心
    2020-12-07 15:55

    You can as well set the current user as the model for your ApplicationRoute like so:

    App.ApplicationRoute = Ember.Route.extend({
        model: function() {
            return App.User.getCurrentUser();
        }
    });
    

    Since getCurrentUser() returns a promise, the transition will suspend until the promise either fulfills or rejects.

    This is handy because by the time transition is finished your model is initialized and you will see it rendered in the template.

    You can read up more about async routing in Ember guides.

提交回复
热议问题