Skip to content

Commit

Permalink
Disallow passing a loaded template
Browse files Browse the repository at this point in the history
  • Loading branch information
fboeller committed Mar 7, 2021
1 parent 3474ab2 commit 5ca41e5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ <h2>Default usage example</h2>
`LoadableModule` is imported with the default loading and error components.
</p>
<app-load-form (loadable)="loadable = $event"></app-load-form>
<div>
<h3>State of the loadable</h3>
<pre>{{ loadable | json }}</pre>
</div>
<ld-loadable [loadable]="loadable">
<h3>Loaded</h3>
<pre>{{ loadable | loadedValue | json }}</pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ export class LoadableComponent implements OnChanges, AfterViewInit {
) {}

updateContent(): void {
if (this.loadingState === 'loaded') {
return;
}
this.templateRef = this.templates[this.loadingState];
const defaultComponent = this.defaultComponents[this.loadingState];
if (!this.templateRef && defaultComponent && this.content) {
this.content.clear();
Expand All @@ -95,10 +99,7 @@ export class LoadableComponent implements OnChanges, AfterViewInit {
}
if ('loadable' in changes || 'templates' in changes) {
this.defaultComponentRef?.destroy();
if (this.loadingState !== 'loaded') {
this.templateRef = this.templates[this.loadingState];
this.updateContent();
}
this.updateContent();
}
}

Expand Down
1 change: 0 additions & 1 deletion projects/ngx-loadable/src/lib/angular/module.options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { LoadableLoadingComponent } from './loadable-loading/loadable-loading.co
export type DefaultComponents = {
idle?: Type<{}>;
loading?: Type<{}>;
loaded?: Type<{ value: any }>;
error?: Type<{ error: any }>;
};

Expand Down

0 comments on commit 5ca41e5

Please sign in to comment.