-
Notifications
You must be signed in to change notification settings - Fork 248
Directives should support module publishing. #652
Comments
@kasperl can you add your thoughts here? |
PR #779 Has an implementation which allows specifying a module. The PR supports two syntaxes at the moment. If we define types as:
Then we can define
or
When using static function we don't have to use reflection to instantiate types. When using just type the end user does not need to worry about specifying static function but there might be some performance penalties. Thoughts? Any other suggestions? @mhevery @pavelgj @jbdeboer @kasperl + anyone else who wants to contribute their thoughts :) |
What's the current thinking on this topic? Are people generally happy with using a static method (module) that can be closurized in a compile-time constant way? Are you still looking for alternatives, @mhevery? |
Closed by: 5ec7e83 |
When the directive is trigger its annotation should allow for modules which would be merged into the injector. In this way the directive could do more then just instantiate itself. It could also override instances, or create a whole collection of instances.
This should replace publishTypes annotation property.
We have a
publishTypes
https://docs.angulardart.org/#angular/angular.NgAnnotation@id_publishTypes annotation.It is used like this
The reason for this is that if we could have multiple directives which implement
SomeInterface
we would like for to inject it asSomeInterface
. The issue is that when the module gets registered it will say something like this:This means that asking for
SomeInterface
will return error. What thepublishTypes
property does is do an extra registration like so:This enables one to ask for
SomeInterface
and getSomeDirective
implementation.But this is really just one specific use case. A more generic case is that a Directive should be able to create a custom module definition which should be loaded into the injector. Then the directive can performa a lot more.
Something like so:
This way not only can a directive implement different types, but it can also publish its own types.
The text was updated successfully, but these errors were encountered: