Last active
December 29, 2015 00:38
-
-
Save narqo/bf7debec89a760e6b007 to your computer and use it in GitHub Desktop.
Yet another concept of async BEMTREE templates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
block('global').def(function() { | |
var data = this.param('req'), | |
host = this.param('apiHost'), | |
params = {}; | |
return async(function() { | |
try { | |
var result = await(this.httpInvoke({ host : host, path : '/some/api' }); | |
var status = result.status; | |
if(!status) { | |
throw new Error('unknown request!'); | |
} | |
params.login = result.login; | |
params.info = result.info; | |
} catch(e) { | |
console.error('Something happend!', e); | |
} | |
this.ctx.params = params; | |
return applyNext(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Это должен быть аналог текущей реализации на промисах:
про проблемы с контекстами я (долго) не думал пока >_>