[feat] Composition through properties decorator
See original GitHub issueI’m submitting a…
[ ] Regression
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
Right now if you’re extending classes and want to use some “objects” in the “parent” class, you have to pass them individual from the child to parent. DI doesn’t handle this behaviour.
Expected behavior
I would like to see something different than DI through constructor, so Composition as property decorator:
export class Foo {
@Composition();
protected bar: Bar;
// logic
}
export class FooChild extends Foo {
constructor(private ownBar: Bar) {
super();
console.assert(this.ownBar === this.bar, 'How does it feel?');
}
}
Minimal reproduction of the problem with instructions
None.
What is the motivation / use case for changing the behavior?
Even better/fancy/sexy dependency injection. This will prevent us to pass deps through constructor, code will looks much more cleaner, less effort.
Decorator Composition
might also takes a some params, like Model from which we would like to get type.
What do you think guys?
Environment
Nest version: 5.1.0
For Tooling issues:
- Node version: v8.11.2
- Platform: Linux
Others:
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:16 (11 by maintainers)
Top Results From Across the Web
The @property Decorator in Python: Its Use Cases ...
The @property is a built-in decorator for the property() function in Python. It is used to give "special" functionality to certain methods to ......
Read more >Swift Property Wrappers - NSHipster
Swift property wrappers go a long way to making SwiftUI possible, ... We'll dive into SwiftUI once it's had a bit longer to...
Read more >Python Decorators in 15 Minutes - YouTube
Decorators are an advanced feature of the Python language that allow you to modify the behavior of a function or method without touching...
Read more >Vue 3 Composition API: Basics and Patterns - Medium
With Composition API, you can organise code into smaller logical ... occur as properties from each mixin are merged into the same component....
Read more >Composition and inheritance | Python 3 Object Oriented ...
This is a common first step in turning an object-oriented analysis into a design. At this point, to emphasize composition, we'll focus on...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
see #1172
@kamilmysliwiec did I told you that I love you? ❤️