question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[feat] Composition through properties decorator

See original GitHub issue

I’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:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:16 (11 by maintainers)

github_iconTop GitHub Comments

5reactions
kamilmysliwieccommented, Oct 6, 2018

see #1172

2reactions
cojackcommented, Oct 7, 2018

@kamilmysliwiec did I told you that I love you? ❤️

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found