- From: Mohamed Ibrahim <notifications@github.com>
- Date: Thu, 08 Jun 2017 11:24:01 -0700
- To: w3c/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Thursday, 8 June 2017 18:25:41 UTC
I found a kinda `dirty` workaround of wrapping the custom elements class in a constructor function where I can do DI and capturing the constructor function arguments in closure and passing them to the inner class(custom elements class)
Here is a simple sudo code of what I mean
```javascript
// I do DI of the dependencies here
function MyComponent(http, bar) {
return class extends HTMLElement {
constructor() {
super()
this.http = http
this.bar = bar
}
}
}
```
For a working version of code, refer https://github.com/ibhi/webcomponent-with-di/blob/master/src/users.component.js
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/605#issuecomment-307186960
Received on Thursday, 8 June 2017 18:25:41 UTC