Questions tagged [newable]
6 questions
9
votes
3 answers
How to specify any newable type in TypeScript?
I tried with this but it doesn't work. Foo is just a test of what works. Bar is the real try, it should receive any newable type but subclasses of Object isn't valid for that purpose.
class A {
}
class B {
public Foo(newable: typeof A):void {
…

Áxel Costas Pena
- 5,886
- 6
- 28
- 59
8
votes
1 answer
Dependency Injection, injecting an "injectable" object (service) into a newable (entity)
When writing code we should be able to identify two big group of objects:
Injectables
Newables
http://www.loosecouplings.com/2011/01/how-to-write-testable-code-overview.html
http://misko.hevery.com/2008/09/30/to-new-or-not-to-new/
Injectable…

Jupaol
- 21,107
- 8
- 68
- 100
7
votes
3 answers
Dependency injection when the class created also needs runtime values?
Assume you divide up your systems in Value objects and Services objects (as suggested in "Growing Object-Oriented Software, Guided by Tests". Misko Hevery calls these "newables" and "injectables".
What happens when one of your value objects…

WW.
- 23,793
- 13
- 94
- 121
4
votes
1 answer
ViewHelper newable/injectable dilemma
I'm trying to design an application following Misko Heverys insights. It's an interesting experiment and a challenge. Currently I'm struggling with my ViewHelper implementation.
The ViewHelper decouples the model from the view. In my implementation…

koen
- 13,349
- 10
- 46
- 51
0
votes
0 answers
Typescript generic callable constructor type
Does typescript provide any means to get a callable constructor properly typed in generic way?
The below code works but has a few issues.
Seems you just can't modify the constructor return type through a declaring class or interface.
I tried to play…

Lode Michels
- 69
- 5
0
votes
1 answer
Is it possible to pass a type to an Angular component that can 'newed'?
I am developing a generic dropdown component. If the user enters a value not in the list, I want to return a new object of the same type in the itemSelected event. I need to preserve the methods as well as the properties - so just creating a generic…

Jon Vote
- 604
- 5
- 17