Comments (3)
@arnederuwe This is expected behavior. When a constructor is registered to be injected, it will be instantiated and value of new String()
call is an empty string.
For NSwag, what you need to do is to register the service client in your main.ts
:
export function configure(aurelia: Aurelia) {
aurelia
.use
.instance(
MyGeneratedServiceClass,
new MyGeneratedServiceClass('http://path/to/my/base/url', aurelia.container.get(HttpClient))
);
}
from dependency-injection.
Thanks for clarifying, I am doing something similar as you are describing to circumvent it:
export function configure(config: FrameworkConfiguration) {
config.container.registerSingleton(
ImageClient,
() => new ImageClient(null, config.container.get(HttpClient))
);
config.container.registerSingleton(
ContainerClient,
() => new ContainerClient(null, config.container.get(HttpClient))
);
config.container.registerSingleton(
CustomerClient,
() => new CustomerClient(null, config.container.get(HttpClient))
);
config.container.registerSingleton(
TenantInfoTokenClient,
() => new TenantInfoTokenClient(null, config.container.get(HttpClient))
);
}
Problem is I'm having a lot of clients, and this code isn't really DRY :) that's why I wanted to use nswag's url resolver function, but that only get's triggered when an undefined is passed to the client. I'll file an issue with NSwag, as there really is no clean way to utilize their resolver function because of this.
from dependency-injection.
@arnederuwe Please link the issue in this, thanks! 😄
from dependency-injection.
Related Issues (20)
- @lazy not working with @autoinject HOT 7
- get rid of aurelia-pal dependency HOT 2
- Optional resolver doesn't work as expected HOT 2
- Proposal for easier way to inject via DI into a view-model HOT 10
- di, nodejs HOT 4
- Missing property in d.ts? HOT 5
- Arrays and the DI Container HOT 26
- Version 1.4.0 does not contain the dist directory HOT 6
- 1.4.0 release and typings. HOT 3
- Unable to jspm bundle aurelia-dependency-injection 1.4 HOT 4
- Bug: Cannot use spread with the injector (Injection With Inheritance in Aurelia) HOT 19
- No access to global Container when used in node npm module HOT 5
- 1.4.2 release typings HOT 25
- error TS1005: ';' expected in TS typings HOT 1
- dependency-injection 1.5.0 incompatible to aurelia-validation 1.4.0 HOT 9
- error TS1110: Type expected HOT 6
- Building project in babel-loader fails on const enum because of --isolatedModules flag HOT 1
- Bug: @newInstance() becomes container default instance if it's the first instance
- Backport `resolve` from Aurelia 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dependency-injection.