Skip to content

Commit

Permalink
docs(lifecyle): fix typo (#3681)
Browse files Browse the repository at this point in the history
  • Loading branch information
chiaweilee authored and atian25 committed May 7, 2019
1 parent f2a7ad9 commit da2d439
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions docs/source/en/basics/app-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class AppBootHook {
// For example: the password in the parameter is encrypted, decrypt it here
this.app.config.mysql.password = decrypt(this.app.config.mysql.password);
// For example: insert a middleware into the framework's coreMiddleware
const statusIdx = app.config.coreMiddleware.indexOf('status');
app.config.coreMiddleware.splice(statusIdx + 1, 0, 'limit');
const statusIdx = this.app.config.coreMiddleware.indexOf('status');
this.app.config.coreMiddleware.splice(statusIdx + 1, 0, 'limit');
}

async didLoad() {
Expand All @@ -46,7 +46,7 @@ class AppBootHook {
await this.app.queue.init();

// For example: load a custom directory
app.loader.loadToContext(path.join(__dirname, 'app/tasks'), 'tasks', {
this.app.loader.loadToContext(path.join(__dirname, 'app/tasks'), 'tasks', {
fieldClass: 'tasksClasses',
});
}
Expand All @@ -57,7 +57,7 @@ class AppBootHook {
// Application will start after these operations executed succcessfully

    // For example: loading data from the database into the in-memory cache
this.app.cacheData = await app.model.query(QUERY_CACHE_SQL);
this.app.cacheData = await this.app.model.query(QUERY_CACHE_SQL);
}

async didReady() {
Expand All @@ -71,7 +71,7 @@ class AppBootHook {
// http / https server has started and begins accepting external requests
    // At this point you can get an instance of server from app.server

app.server.on('timeout', socket => {
this.app.server.on('timeout', socket => {
// handle socket timeout
});
}
Expand All @@ -80,4 +80,4 @@ class AppBootHook {

**Note: It is not recommended to do long-time operations in the custom lifecycle function, because the framework has a startup timeout detection.**

If your Egg's life-cycle functions are old, we suggest you upgrading to the "class-method" mode. For more you can refer to [Upgrade your event functions in your lifecycle](../advanced/loaderUpdate.md).
If your Egg's life-cycle functions are old, we suggest you upgrading to the "class-method" mode. For more you can refer to [Upgrade your event functions in your lifecycle](../advanced/loaderUpdate.md).
12 changes: 6 additions & 6 deletions docs/source/zh-cn/basics/app-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class AppBootHook {
// 例如:参数中的密码是加密的,在此处进行解密
this.app.config.mysql.password = decrypt(this.app.config.mysql.password);
// 例如:插入一个中间件到框架的 coreMiddleware 之间
const statusIdx = app.config.coreMiddleware.indexOf('status');
app.config.coreMiddleware.splice(statusIdx + 1, 0, 'limit');
const statusIdx = this.app.config.coreMiddleware.indexOf('status');
this.app.config.coreMiddleware.splice(statusIdx + 1, 0, 'limit');
}

async didLoad() {
Expand All @@ -45,7 +45,7 @@ class AppBootHook {
await this.app.queue.init();

// 例如:加载自定义的目录
app.loader.loadToContext(path.join(__dirname, 'app/tasks'), 'tasks', {
this.app.loader.loadToContext(path.join(__dirname, 'app/tasks'), 'tasks', {
fieldClass: 'tasksClasses',
});
}
Expand All @@ -55,7 +55,7 @@ class AppBootHook {
// 可以做一些数据初始化等操作,这些操作成功才会启动应用

// 例如:从数据库加载数据到内存缓存
this.app.cacheData = await app.model.query(QUERY_CACHE_SQL);
this.app.cacheData = await this.app.model.query(QUERY_CACHE_SQL);
}

async didReady() {
Expand All @@ -69,7 +69,7 @@ class AppBootHook {
// http / https server 已启动,开始接受外部请求
// 此时可以从 app.server 拿到 server 的实例

app.server.on('timeout', socket => {
this.app.server.on('timeout', socket => {
// handle socket timeout
});
}
Expand All @@ -78,4 +78,4 @@ class AppBootHook {

**注意:在自定义生命周期函数中不建议做太耗时的操作,框架会有启动的超时检测。**

如果你的 Egg 框架的生命周期函数是旧版本的,建议你升级到类方法模式;详情请查看[升级你的生命周期事件函数](../advanced/loaderUpdate.md)
如果你的 Egg 框架的生命周期函数是旧版本的,建议你升级到类方法模式;详情请查看[升级你的生命周期事件函数](../advanced/loaderUpdate.md)

0 comments on commit da2d439

Please sign in to comment.