Skip to content

Commit

Permalink
Add new events for debugging purposes
Browse files Browse the repository at this point in the history
  • Loading branch information
skerit committed Dec 13, 2015
1 parent 70e4b45 commit a8c9ed0
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/class/view_render.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ module.exports = function(Hawkejs, Blast) {

// Emit an event that we're going to render
this.hawkejs.emit({type: 'viewrender', status: 'begin', client: this.clientRender}, this);
this.emit('begin', this);
this.emit('begin', templates);

// Return early if this is meant for the browser, but remain asynchronous
if (this.clientRender && Blast.isNode) {
Expand All @@ -558,13 +558,20 @@ module.exports = function(Hawkejs, Blast) {

Blast.setImmediate(function sendingData() {

var result;

// Send JSON data if this is meant to be rendered in the browser
that.res.setHeader('content-type', 'application/json-dry; charset=utf-8');

// Remove the baseId, the client will have to reset that themselves
that.baseId = null;

return callback(null, Blast.Collection.JSON.dry(that), false);
// Dry the data
result = Blast.Collection.JSON.dry(that);

that.emit('dry_response', result);

return callback(null, result, false);
});

return;
Expand All @@ -576,6 +583,8 @@ module.exports = function(Hawkejs, Blast) {
// Initialize all the helpers
this.initHelpers();

this.emit('executing', templates);

log(1, 'Executing', templates.getNames());

// @todo: allow multiple template options
Expand Down Expand Up @@ -914,10 +923,13 @@ module.exports = function(Hawkejs, Blast) {
}

log(5, 'Requesting join of entire block', blockName);
this.emit('finishing_block', blockName);

// Join the block's buffer
block.joinBuffer(function joinedBuffer(err, html, block) {

that.emit('finished_block', blockName);

if (err) {
log(4, 'Joined block', blockName, ', but got error:', err);
return callback(err);
Expand Down

0 comments on commit a8c9ed0

Please sign in to comment.