Skip to content

Commit 9628391

Browse files
committed
Merge pull request ember-fastboot#41 from danmcclain/deferred-rendering
Defer rendering via promise chaining
2 parents 9ca312b + d376b91 commit 9628391

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/ember-app.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ EmberApp.prototype.visit = function(path, options) {
8686
.then(function(instance) {
8787
return instance.visit(path, bootOptions);
8888
})
89+
.then(function(instance) {
90+
var fastbootInfo = instance.lookup('info:-fastboot');
91+
92+
return fastbootInfo.deferredPromise.then(function() {
93+
return instance;
94+
});
95+
})
8996
.then(serializeHTML(doc, rootElement));
9097
};
9198

lib/fastboot-info.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
var RSVP = require('rsvp');
12
var FastBootRequest = require('./fastboot-request');
23

34
/*
@@ -7,9 +8,16 @@ var FastBootRequest = require('./fastboot-request');
78
*/
89
function FastBootInfo(request, response, hostWhitelist) {
910
this.response = response;
11+
this.deferredPromise = RSVP.resolve();
1012
this.request = new FastBootRequest(request, hostWhitelist);
1113
}
1214

15+
FastBootInfo.prototype.deferRendering = function(promise) {
16+
this.deferredPromise = this.deferredPromise.then(function() {
17+
return promise;
18+
});
19+
}
20+
1321
/*
1422
* Registers this FastBootInfo instance in the registry of an Ember
1523
* ApplicationInstance. It is configured to be injected into the FastBoot

0 commit comments

Comments
 (0)