Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(boot): improve service booter to load classes decorated with @Bind
- Loading branch information
1 parent
88eff77
commit 48e01f4
Showing
5 changed files
with
102 additions
and
34 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
packages/boot/src/__tests__/fixtures/bindable-classes.artifact.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,35 @@ | ||
// Copyright IBM Corp. 2019. All Rights Reserved. | ||
// Node module: @loopback/boot | ||
// This file is licensed under the MIT License. | ||
// License text available at https://opensource.org/licenses/MIT | ||
|
||
import {bind, BindingScope, Provider} from '@loopback/core'; | ||
|
||
@bind({ | ||
tags: {serviceType: 'local'}, | ||
scope: BindingScope.SINGLETON, | ||
}) | ||
export class BindableGreetingService { | ||
greet(whom: string = 'world') { | ||
return Promise.resolve(`Hello ${whom}`); | ||
} | ||
} | ||
|
||
@bind({tags: {serviceType: 'local', name: 'CurrentDate'}}) | ||
export class DateProvider implements Provider<Date> { | ||
value(): Promise<Date> { | ||
return Promise.resolve(new Date()); | ||
} | ||
} | ||
|
||
export class NotBindableGreetingService { | ||
greet(whom: string = 'world') { | ||
return Promise.resolve(`Hello ${whom}`); | ||
} | ||
} | ||
|
||
export class NotBindableDateProvider implements Provider<Date> { | ||
value(): Promise<Date> { | ||
return Promise.resolve(new Date()); | ||
} | ||
} |
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