-
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.
feat: add LifecyclePreStandaloneLoad
- Loading branch information
1 parent
27fd9ff
commit a737bfa
Showing
8 changed files
with
151 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { | ||
SingletonProto, | ||
LifecyclePreStandaloneLoad, | ||
LifecyclePostConstruct, | ||
LifecyclePreInject, | ||
LifecyclePostInject, | ||
LifecycleInit, | ||
LifecyclePreDestroy, | ||
LifecycleDestroy, | ||
} from '@eggjs/tegg'; | ||
import { Runner, MainRunner } from '@eggjs/tegg/standalone'; | ||
|
||
@Runner() | ||
@SingletonProto() | ||
export class Foo implements MainRunner<string[]> { | ||
private called: string[] = []; | ||
|
||
static staticCalled: string[] = []; | ||
|
||
getLifecycleCalled() { | ||
return this.called; | ||
} | ||
|
||
@LifecyclePreStandaloneLoad() | ||
static async _preStandaloneLoad() { | ||
Foo.staticCalled.push('preStandaloneLoad'); | ||
} | ||
|
||
constructor() { | ||
this.called.push('construct'); | ||
} | ||
|
||
@LifecyclePostConstruct() | ||
protected async _postConstruct() { | ||
this.called.push('postConstruct'); | ||
} | ||
|
||
@LifecyclePreInject() | ||
protected async _preInject() { | ||
this.called.push('preInject'); | ||
} | ||
|
||
@LifecyclePostInject() | ||
protected async _postInject() { | ||
this.called.push('postInject'); | ||
} | ||
|
||
protected async init() { | ||
this.called.push('init should not called'); | ||
} | ||
|
||
@LifecycleInit() | ||
protected async _init() { | ||
this.called.push('init'); | ||
} | ||
|
||
@LifecyclePreDestroy() | ||
protected async _preDestroy() { | ||
this.called.push('preDestroy'); | ||
} | ||
|
||
@LifecycleDestroy() | ||
protected async _destroy() { | ||
this.called.push('destroy'); | ||
} | ||
|
||
async main(): Promise<string[]> { | ||
return this.called; | ||
} | ||
} |
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