-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat: view base promise to support async function #343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -296,10 +296,10 @@ function loadFilter() { | |
| - 该子类会在原 render 方法的基础上,增加对 locals 的注入。 | ||
|
|
||
| 有兴趣的同学可以看下对应的源码: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 上面的 app.View 那段好像不准确了吧? @popomore 貌似改过了.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 哪一段?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 那个另起 PR 改吧,这次只改 generator function 相关的
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 嗯 |
||
| - [app/extend/context.js](https://github.com/eggjs/egg/blob/master/app/extend/context.js), `* render()` | ||
| - [app/extend/context.js](https://github.com/eggjs/egg/blob/master/app/extend/context.js), `render()` | ||
| - [app/extend/application.js](https://github.com/eggjs/egg/blob/master/app/extend/application.js), `get View()` | ||
| - [lib/core/view.js](https://github.com/eggjs/egg/blob/master/lib/core/view.js) | ||
|
|
||
|
|
||
| [egg-security]: https://github.com/eggjs/egg-security | ||
| [egg-view-nunjucks]: https://github.com/eggjs/egg-view-nunjucks | ||
| [egg-view-nunjucks]: https://github.com/eggjs/egg-view-nunjucks | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
| return new (P || (P = Promise))(function (resolve, reject) { | ||
| function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
| function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } | ||
| function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
| step((generator = generator.apply(thisArg, _arguments)).next()); | ||
| }); | ||
| }; | ||
|
|
||
| module.exports = app => { | ||
| return class AsyncController extends app.Controller { | ||
| index() { | ||
| const ctx = this.ctx; | ||
| return __awaiter(this, void 0, void 0, function* () { | ||
| yield ctx.render('index.html', {name: 'mk・2'}); | ||
| }); | ||
| } | ||
| } | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里还涉及到几个地方的关联修改:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
喔, 记错了, 插件里面就是 promise .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://eggjs.org/zh-cn/advanced/view-plugin.html
底部那里要改下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
恩,基类我看都是 promise base
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
文档中的
* render()改掉了