-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
27fd9ff
commit b3add61
Showing
11 changed files
with
173 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { | ||
SingletonProto, | ||
LifecyclePreLoad, | ||
LifecyclePostConstruct, | ||
LifecyclePreInject, | ||
LifecyclePostInject, | ||
LifecycleInit, | ||
LifecyclePreDestroy, | ||
LifecycleDestroy, | ||
} from '@eggjs/tegg'; | ||
import { Runner, MainRunner } from '@eggjs/tegg/standalone'; | ||
|
||
@Runner() | ||
@SingletonProto() | ||
export class Foo implements MainRunner<string[]> { | ||
|
||
static staticCalled: string[] = []; | ||
|
||
getLifecycleCalled() { | ||
return Foo.staticCalled; | ||
} | ||
|
||
@LifecyclePreLoad() | ||
static async _preLoad() { | ||
Foo.staticCalled.push('preLoad'); | ||
} | ||
|
||
constructor() { | ||
Foo.staticCalled.push('construct'); | ||
} | ||
|
||
@LifecyclePostConstruct() | ||
protected async _postConstruct() { | ||
Foo.staticCalled.push('postConstruct'); | ||
} | ||
|
||
@LifecyclePreInject() | ||
protected async _preInject() { | ||
Foo.staticCalled.push('preInject'); | ||
} | ||
|
||
@LifecyclePostInject() | ||
protected async _postInject() { | ||
Foo.staticCalled.push('postInject'); | ||
} | ||
|
||
protected async init() { | ||
Foo.staticCalled.push('init should not called'); | ||
} | ||
|
||
@LifecycleInit() | ||
protected async _init() { | ||
Foo.staticCalled.push('init'); | ||
} | ||
|
||
@LifecyclePreDestroy() | ||
protected async _preDestroy() { | ||
Foo.staticCalled.push('preDestroy'); | ||
} | ||
|
||
@LifecycleDestroy() | ||
protected async _destroy() { | ||
Foo.staticCalled.push('destroy'); | ||
} | ||
|
||
async main(): Promise<string[]> { | ||
return Foo.staticCalled; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "lifecycle", | ||
"eggModule": { | ||
"name": "lifecycle" | ||
} | ||
} |
This file contains 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