-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(api): replace deprecated
DynamicModule
with component module
BREAKING CHANGE: Previously deprecated module contained all the pieces of public API in on module and this was not tree-shakeable. Now it has been removed and replaced by the module that only contains `DynamicComponent`. All other pieces are available in their own modules.
- Loading branch information
Showing
3 changed files
with
7 additions
and
76 deletions.
There are no files selected for viewing
12 changes: 0 additions & 12 deletions
12
projects/ng-dynamic-component/src/lib/dynamic.component.module.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,12 @@ | ||
import { ModuleWithProviders, NgModule, Type } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { NgModule } from '@angular/core'; | ||
|
||
import { | ||
ComponentOutletInjectorModule, | ||
DynamicComponentInjector, | ||
DynamicComponentInjectorToken, | ||
} from './component-injector'; | ||
import { DynamicAttributesModule } from './dynamic-attributes'; | ||
import { DynamicDirectivesModule } from './dynamic-directives'; | ||
import { DynamicIoModule } from './dynamic-io'; | ||
import { DynamicComponent } from './dynamic.component'; | ||
import { DynamicComponentModule } from './dynamic.component.module'; | ||
|
||
/** | ||
* @deprecated Since v6.0.0 - use more specific module instead: | ||
* - {@link DynamicIoModule} | ||
* - {@link DynamicComponentModule} | ||
* - {@link DynamicAttributesModule} | ||
* - {@link DynamicDirectivesModule} | ||
* - {@link ComponentOutletInjectorModule} | ||
*/ | ||
@NgModule({ | ||
exports: [ | ||
ComponentOutletInjectorModule, | ||
DynamicIoModule, | ||
DynamicComponentModule, | ||
DynamicAttributesModule, | ||
DynamicDirectivesModule, | ||
], | ||
imports: [CommonModule, DynamicIoModule], | ||
exports: [DynamicComponent, DynamicIoModule], | ||
declarations: [DynamicComponent], | ||
}) | ||
export class DynamicModule { | ||
/** | ||
* @deprecated Since v6.0.0 - forRoot is not required anymore. | ||
* Provide {@link DynamicComponentInjectorToken} on the component level instead of global! | ||
* | ||
* **Example:** | ||
* ```ts | ||
* @Component({ | ||
* selector: '...', | ||
* providers: [{provide: DynamicComponentInjectorToken, useExisting: MyInjectorComponent}] | ||
* }) | ||
* class MyInjectorComponent implements DynamicComponentInjector {...} | ||
* ``` | ||
*/ | ||
static forRoot( | ||
componentInjector: Type<DynamicComponentInjector> = DynamicComponent, | ||
): ModuleWithProviders<DynamicModule> { | ||
return { | ||
ngModule: DynamicModule, | ||
providers: [ | ||
{ | ||
provide: DynamicComponentInjectorToken, | ||
useExisting: componentInjector, | ||
}, | ||
], | ||
}; | ||
} | ||
|
||
/** | ||
* @deprecated Since v6.0.0 - Passing a list of components is no longer required. Use `DynamicModule.forRoot()` instead. | ||
*/ | ||
static withComponents( | ||
components: Type<any>[], | ||
componentInjector?: Type<DynamicComponentInjector>, | ||
): ModuleWithProviders<DynamicModule> { | ||
return DynamicModule.forRoot(componentInjector); | ||
} | ||
} | ||
export class DynamicModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters