Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vilicvane/entrance-decorator
A minimal solution of dependency injection for projects that scale.
https://github.com/vilicvane/entrance-decorator
dependency-injection
Last synced: 20 days ago
JSON representation
A minimal solution of dependency injection for projects that scale.
- Host: GitHub
- URL: https://github.com/vilicvane/entrance-decorator
- Owner: vilicvane
- License: mit
- Created: 2020-02-21T02:41:13.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-11-01T14:46:06.000Z (about 1 year ago)
- Last Synced: 2024-11-30T15:41:55.201Z (23 days ago)
- Topics: dependency-injection
- Language: TypeScript
- Homepage:
- Size: 540 KB
- Stars: 25
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Entrance Decorator
A minimal solution of dependency injection for projects that scale.
## Why
🙂
## Installation
```
yarn add entrance-decorator
```## Usage
### Define entrances
```ts
import {entrance} from 'entrance-decorator';export class Entrances {
constructor(private url: string) {}@entrance
get uiService() {
return new UIService(this.errorService);
}@entrance
get errorService() {
return new ErrorService({
baseURL: this.url,
});
}
}
```### Extend/override entrances
```ts
import {entrance} from 'entrance-decorator';export class MobileEntrances extends Entrances {
// Extend entrance
@entrance
get mobileService() {
return new MobileService(this.errorService);
}// Override entrance
@entrance
get uiService() {
return new MobileUIService(this.errorService);
}
}
```### Use entrances
```ts
const entrances = new Entrances('https://makeflow.com');
```You may use the `entrances` object in whatever way you want. For example, we use `Context` in React (in a decorator manner) and use something like `entrances.launchServer()` in server-side applications.
## What it does
Cache and circular dependency check, nothing else.
## License
MIT License.