-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jason C. Leach <jason.leach@fullboar.ca>
- Loading branch information
Showing
10 changed files
with
111 additions
and
94 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,29 @@ | ||
import { BaseLogger } from '@credo-ts/core' | ||
import { Container, TokenMapping } from '@hyperledger/aries-bifold-core' | ||
import { DependencyContainer } from 'tsyringe' | ||
|
||
export class AppContainer implements Container { | ||
private container: DependencyContainer | ||
public constructor(bifoldContainer: Container) { | ||
this.container = bifoldContainer.getContainer().createChildContainer() | ||
private _container: DependencyContainer | ||
private log?: BaseLogger | ||
|
||
public constructor(bifoldContainer: Container, log?: BaseLogger) { | ||
this._container = bifoldContainer.container.createChildContainer() | ||
this.log = log | ||
} | ||
|
||
public get container(): DependencyContainer { | ||
return this._container | ||
} | ||
|
||
public init(): Container { | ||
// eslint-disable-next-line no-console | ||
console.log(`Initializing App container`) | ||
this.log?.info(`Initializing App container`) | ||
// Here you can register any component to override components in core package | ||
// Example: Replacing button in core with custom button | ||
// this.container.registerInstance(TOKENS.COMP_BUTTON, Button) | ||
return this | ||
} | ||
|
||
public resolve<K extends keyof TokenMapping>(token: K): TokenMapping[K] { | ||
return this.container.resolve(token) as TokenMapping[K] | ||
} | ||
|
||
public getContainer(): DependencyContainer { | ||
return this.container | ||
return this._container.resolve(token) as TokenMapping[K] | ||
} | ||
} |
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