This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/mixins/model_ready.js

30 lines
755 B
JavaScript

/**
Until the fully async router is merged into Ember, it is healthy to do some extra checking
that setupController is not passed a promise instead of the model we want.
This mixin handles that case, and calls modelReady instead.
@class Discourse.ModelReady
@extends Ember.Mixin
@namespace Discourse
@module Discourse
**/
Discourse.ModelReady = Em.Mixin.create({
setupController: function(controller, model) {
var route = this;
if (model.then) {
model.then(function (m) {
controller.set('model', m);
if (route.modelReady) { route.modelReady(controller, m); }
});
} else {
controller.set('model', model);
if (route.modelReady) { route.modelReady(controller, model); }
}
}
});