Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accommodate constructor-based DI for custom elements #15804

Closed
DartBot opened this issue Dec 26, 2013 · 7 comments
Closed

Accommodate constructor-based DI for custom elements #15804

DartBot opened this issue Dec 26, 2013 · 7 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. library-html P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug web-libraries Issues impacting dart:html, etc., libraries

Comments

@DartBot
Copy link

DartBot commented Dec 26, 2013

This issue was originally filed by @bgourlie


It would be really nice to have constructor-based DI available for polymer components. I know .NET's MVC framework accommodates this by defining an IDependencyResolver interface (http://msdn.microsoft.com/en-us/library/system.web.mvc.idependencyresolver(v=vs.118).aspx) which abstracts away the DI implementation.

@sigmundch
Copy link
Member

Yeah, I heard others request something similar.

The main challenge here is that the html parser is doing the object allocation for us. Currently document.registerElement only takes a type argument for this, but there has been some discussion about adding a second argument on that can be used to supply the arguments needed for the constructor call.

Meanwhile, I've seen others follow a pattern where they add an extra polymer-element that does the injection for you. For example:

Instead of:
<my-real-tag ... >

You write:
<dependency-injected tag="my-real-tag">

where internally dependency-injected is a custom element that calls <my-real-tag>'s constructor and injects the arguments immediately afterwards. The arguments are not available right away when the .created constructor is called, but there should become available on the enteredView callback.


cc @blois.
Added Area-Polymer, Triaged labels.

@blois
Copy link
Contributor

blois commented Dec 27, 2013

The primary difficulty here is getting Dart VM and JS semantics the same- in Dart we construct a separate wrapper when elements are upgraded, but in JS the same wrapper is used in both scenarios. This means that the 'created' constructor is quite special in JS- to support DI we'd need to propagate a lot of this special-ness.

@sigmundch
Copy link
Member

Removed Area-Polymer label.
Added Area-HTML label.
Changed the title to: "Accommodate constructor-based DI for custom elements".

@kevmoo
Copy link
Member

kevmoo commented Apr 7, 2014

Removed Area-HTML label.
Added Area-Library, Library-Html labels.

@efortuna
Copy link
Contributor

Removed Type-Defect label.
Added Type-Enhancement label.

@alan-knight
Copy link
Contributor

cc @sigmundch.
Removed Priority-Unassigned label.
Added Priority-Medium label.

@DartBot DartBot added Type-Enhancement area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-html labels Jan 16, 2015
@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug and removed triaged labels Mar 1, 2016
@vsmenon vsmenon added the area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. label Jul 20, 2019
@sigmundch sigmundch added the web-libraries Issues impacting dart:html, etc., libraries label Oct 25, 2021
@kevmoo
Copy link
Member

kevmoo commented May 6, 2022

We're going to deprecate registerElement

@kevmoo kevmoo closed this as completed May 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. library-html P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug web-libraries Issues impacting dart:html, etc., libraries
Projects
None yet
Development

No branches or pull requests

7 participants