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

Can't extend IterableDiffers #11309

Closed
barbatus opened this issue Sep 3, 2016 · 20 comments
Closed

Can't extend IterableDiffers #11309

barbatus opened this issue Sep 3, 2016 · 20 comments
Labels
area: core Issues related to the framework runtime core: differs freq1: low P4 A relatively minor issue that is not relevant to core functions type: bug/fix workaround1: obvious
Milestone

Comments

@barbatus
Copy link

barbatus commented Sep 3, 2016

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

Not sure If I am missing something or it's a bug.
But if you do as follows I get "Cannot extend IterableDiffers without a parent injector" exception.

@NgModule({
  imports: [BrowserModule],
  providers: [IterableDiffers.extend([new FooIterableDifferFactory()])]
  bootstrap: [Foo]
});
export class AppModule { }

platformBrowserDynamic().bootstrapModule(AppModule);

Expected/desired behavior

It's possible to extend default iterable differs in the application module.

Please tell us about your environment:

  • Angular version: 2.0.0-rc.6
  • Browser: [all]
  • Language: [all]
@vicb
Copy link
Contributor

vicb commented Sep 5, 2016

Expected/desired behavior

Pls expand on what you're trying to do

@Urigo
Copy link

Urigo commented Sep 5, 2016

As @barbatus said, it's was possible to extend default iterable differs in Components, like here, but now it's not anymore, only available in module providers.

@vicb we are using it in angular2-meteor in order to provide new iterable for Mongo Cursor changes (you can see this file).

As I understand, we moved to use ES6 bundle in the latest version and so we can't access the internal code, so it related to that issue were we asked to export that code for external usage.

Thanks!

@vicb
Copy link
Contributor

vicb commented Sep 6, 2016

Could you please craft a before/after plunker - is this broken in RC6 ?

It's true that deep imports are not allowed any more, might be the issue.

Thanks

@barbatus
Copy link
Author

barbatus commented Sep 7, 2016

@vicb Here is a plunker where a custom differ factory is supposed to be used but it throws "Cannot extend IterableDiffers without a parent injector" when I am trying to use IterableDiffers.extend.
https://plnkr.co/edit/YVRZ6gNq7LMr2DAJvRAf?p=preview

As before, we extended standard differs by providing new instance of IterableDiffers with all differ factories added plus our custom differ factory. In order to get all available differ factories to pass them into IterableDiffers constructor, we relied on some internal code, i.e. https://github.com/Urigo/angular2-meteor/blob/master/modules/providers.ts#L6

It's be awesome if you made access to the standard differ factory public (i.e. this one
https://github.com/angular/angular/blob/master/modules/%40angular/core/src/change_detection/change_detection.ts#L35), so we could use it to extend IterableDiffers in the same way as before,
or made IterableDiffers.extend is not dependable on the default differ.

@vicb vicb self-assigned this Sep 7, 2016
@mhevery mhevery added area: core Issues related to the framework runtime and removed comp: core labels Sep 7, 2016
@htafolla
Copy link

htafolla commented Sep 15, 2016

@vicb is this scheduled to be resolved in the next maintenance release? There is a growing community looking to use Angular 2.0.0 with Meteor. Based on the latest posts on the corresponding thread, this item is the only one remaining to make the jump.

@vicb
Copy link
Contributor

vicb commented Sep 15, 2016

@htafolla I'm going to take a look asap.

@vicb vicb added this to the 2.0.1 milestone Sep 16, 2016
@vicb
Copy link
Contributor

vicb commented Sep 16, 2016

just discussed with @vsavkin, we should have a solution by the next release (probably 2.0.1)

@vicb
Copy link
Contributor

vicb commented Sep 21, 2016

for now a workaround would be not to add the providers in the app module but in a child module.

@barbatus
Copy link
Author

@vicb I added it to a module https://plnkr.co/edit/UCKeZGwKfENQY76RHgiy?p=preview, still same exception. I also tried as ModuleWithProviders, also doesn't help.

@chrisse27
Copy link
Contributor

@barbatus Adding it as provider to the child component works for me: https://plnkr.co/edit/IZcErDswbe6CLSZOwVve

That's also what I did with the METEOR_PROVIDERs to get rid of the exception in my angular2 meteor project.

@barbatus
Copy link
Author

barbatus commented Sep 24, 2016

@chrisse27 yes, but providers for things like IterableDiffers make sense to set globally for all components not for every one.

@chrisse27
Copy link
Contributor

@barbatus I agree, but if I set the provider on my app component then it will be available in all injectors of child components as well.

@barbatus
Copy link
Author

@chrisse27 hm, this is how it was before. I thought for some reason they got (or gonna get) rid of providers in components. Anyways makes sense to fix it for modules as well.

@barbatus
Copy link
Author

@chrisse27 this also https://angular.io/docs/ts/latest/cookbook/ngmodule-faq.html#!#q-component-or-module. For the apps with routes, there is no one root component as well.

@vicb vicb modified the milestones: 2.0.1, 2.0.2 Sep 29, 2016
@vsavkin vsavkin unassigned vsavkin and vicb Nov 16, 2016
@vicb vicb removed this from the 2.0.2 milestone Dec 28, 2016
@DzmitryShylovich
Copy link
Contributor

@barbatus did your solve the issue?

@barbatus
Copy link
Author

barbatus commented Jan 3, 2017

@DzmitryShylovich I could only work around it. Status of this issue clear states it's not fixed yet.
So either a fix is needed or docs update to note that IterableDiffers is not extendable in @NgModule.

@DzmitryShylovich
Copy link
Contributor

@barbatus could u add a small repro in plunkr?

@barbatus
Copy link
Author

barbatus commented Jan 9, 2017

@DzmitryShylovich ok, there was one above which seems to be broken now.
Here is new one https://plnkr.co/edit/tpl:AvJOMERrnz94ekVua0u5?p=preview

UPD: correct link https://plnkr.co/edit/wV5vrEOStbpH1Vmq1n0B?p=preview

@staeke
Copy link

staeke commented Jul 18, 2017

Ping! What's the status of this @DzmitrySchylovic?

@ngbot ngbot bot added this to the Backlog milestone Jan 23, 2018
trotyl added a commit to trotyl/angular that referenced this issue Jul 21, 2018
trotyl added a commit to trotyl/angular that referenced this issue Jul 21, 2018
trotyl added a commit to trotyl/angular that referenced this issue Jul 21, 2018
trotyl added a commit to trotyl/angular that referenced this issue Jul 21, 2018
@jelbourn jelbourn added P4 A relatively minor issue that is not relevant to core functions and removed severity2: inconvenient labels Oct 1, 2020
mhevery added a commit to mhevery/angular that referenced this issue Dec 4, 2020
Differs tries to inject parent differ in order to support extending.
This does not work in the 'root' injector as the provider overrides the
default injector. The fix is to just assume standard set of providers
and extend those instead.

PR Close angular#25015
Issue close angular#11309 `Can't extend IterableDiffers`
Issue close angular#18554 `IterableDiffers.extend is not AOT compatible`
  This is fixed because we no longer have an arrow function in the
  factory but a proper function which can be imported.
mhevery added a commit to mhevery/angular that referenced this issue Dec 5, 2020
Differs tries to inject parent differ in order to support extending.
This does not work in the 'root' injector as the provider overrides the
default injector. The fix is to just assume standard set of providers
and extend those instead.

PR Close angular#25015
Issue close angular#11309 `Can't extend IterableDiffers`
Issue close angular#18554 `IterableDiffers.extend is not AOT compatible`
  This is fixed because we no longer have an arrow function in the
  factory but a proper function which can be imported.
mhevery added a commit to mhevery/angular that referenced this issue Dec 5, 2020
Differs tries to inject parent differ in order to support extending.
This does not work in the 'root' injector as the provider overrides the
default injector. The fix is to just assume standard set of providers
and extend those instead.

PR close angular#25015
Issue close angular#11309 `Can't extend IterableDiffers`
Issue close angular#18554 `IterableDiffers.extend is not AOT compatible`
  (This is fixed because we no longer have an arrow function in the
  factory but a proper function which can be imported.)
mhevery added a commit to mhevery/angular that referenced this issue Dec 5, 2020
Differs tries to inject parent differ in order to support extending.
This does not work in the 'root' injector as the provider overrides the
default injector. The fix is to just assume standard set of providers
and extend those instead.

PR close angular#25015
Issue close angular#11309 `Can't extend IterableDiffers`
Issue close angular#18554 `IterableDiffers.extend is not AOT compatible`
  (This is fixed because we no longer have an arrow function in the
  factory but a proper function which can be imported.)
@mhevery mhevery closed this as completed in 5fc4508 Dec 7, 2020
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: core Issues related to the framework runtime core: differs freq1: low P4 A relatively minor issue that is not relevant to core functions type: bug/fix workaround1: obvious
Projects
None yet