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: 11 months 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 (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-11-01T14:46:06.000Z (over 2 years ago)
- Last Synced: 2025-07-25T03:07:40.208Z (11 months ago)
- Topics: dependency-injection
- Language: TypeScript
- Homepage:
- Size: 540 KB
- Stars: 24
- Watchers: 0
- 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.