Skip to content

Commit

Permalink
fix: improve lifecycle deprecated message (#275)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Bug Fixes**
- Updated deprecation messages for `beforeStart`, `readyCallback`, and
`beforeClose` methods to clarify recommended alternatives.

- **Documentation**
- Enhanced clarity regarding deprecated features and their replacements
in method documentation.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
fengmk2 authored Dec 18, 2024
1 parent 7a4f340 commit ff906ee
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/egg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export class EggCore extends KoaApplication {
* @param {string} [name] scope name, default is empty string
*/
beforeStart(scope: Fun, name?: string) {
this.deprecate('Please use "Life Cycles" instead, see https://www.eggjs.org/advanced/loader#life-cycles');
this.deprecate('`beforeStart` was deprecated, please use "Life Cycles" instead, see https://www.eggjs.org/advanced/loader#life-cycles');
this.lifecycle.registerBeforeStart(scope, name ?? '');
}

Expand Down Expand Up @@ -276,7 +276,7 @@ export class EggCore extends KoaApplication {
* mysql.ready(done);
*/
readyCallback(name: string, opts: object) {
this.deprecate('Please use "Life Cycles" instead, see https://www.eggjs.org/advanced/loader#life-cycles');
this.deprecate('`readyCallback` was deprecated, please use "Life Cycles" instead, see https://www.eggjs.org/advanced/loader#life-cycles');
return this.lifecycle.legacyReadyCallback(name, opts);
}

Expand All @@ -293,7 +293,7 @@ export class EggCore extends KoaApplication {
* @param {Function} fn - the function that can be generator function or async function.
*/
beforeClose(fn: Fun) {
this.deprecate('Please use "Life Cycles" instead, see https://www.eggjs.org/advanced/loader#life-cycles');
this.deprecate('`beforeClose` was deprecated, please use "Life Cycles" instead, see https://www.eggjs.org/advanced/loader#life-cycles');
this.lifecycle.registerBeforeClose(fn);
}

Expand Down

0 comments on commit ff906ee

Please sign in to comment.