-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(example-express-composition): add code path to allow life cycle …
…observers See #3878
- Loading branch information
1 parent
2c5a131
commit 8d3401d
Showing
5 changed files
with
64 additions
and
7 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
37 changes: 37 additions & 0 deletions
37
examples/express-composition/src/observers/hello.observer.ts
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,37 @@ | ||
// Copyright IBM Corp. 2019. All Rights Reserved. | ||
// Node module: @loopback/example-express-composition | ||
// This file is licensed under the MIT License. | ||
// License text available at https://opensource.org/licenses/MIT | ||
|
||
import { | ||
lifeCycleObserver, // The decorator | ||
LifeCycleObserver, | ||
} from '@loopback/core'; | ||
|
||
/** | ||
* This class will be bound to the application as a `LifeCycleObserver` during | ||
* `boot` | ||
*/ | ||
@lifeCycleObserver() | ||
export class HelloObserver implements LifeCycleObserver { | ||
events: string[] = []; | ||
/* | ||
constructor( | ||
@inject(CoreBindings.APPLICATION_INSTANCE) private app: Application, | ||
) {} | ||
*/ | ||
|
||
/** | ||
* This method will be invoked when the application starts | ||
*/ | ||
async start(): Promise<void> { | ||
this.events.push(`${new Date()}: hello-start`); | ||
} | ||
|
||
/** | ||
* This method will be invoked when the application stops | ||
*/ | ||
async stop(): Promise<void> { | ||
this.events.push(`${new Date()}: hello-stop`); | ||
} | ||
} |
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 @@ | ||
// Copyright IBM Corp. 2019. All Rights Reserved. | ||
// Node module: @loopback/example-express-composition | ||
// This file is licensed under the MIT License. | ||
// License text available at https://opensource.org/licenses/MIT | ||
|
||
export * from './hello.observer'; |
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