mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-11 03:16:48 +03:00
Minor refactoring in json-schema-lazy
This commit is contained in:
parent
c40de56a71
commit
18c3f605a0
|
@ -35,19 +35,23 @@ export class JsonSchemaLazy {
|
|||
return schema && schema.$ref || this.pointer;
|
||||
}
|
||||
|
||||
_loadAfterSelf() {
|
||||
return this.dcl.loadNextToLocation(JsonSchema, this.viewRef).then((compRef) => {
|
||||
this.initComponent(compRef);
|
||||
if (compRef.changeDetectorRef) {
|
||||
compRef.changeDetectorRef.detectChanges();
|
||||
} else {
|
||||
compRef.hostView.changeDetectorRef.detectChanges();
|
||||
}
|
||||
return compRef;
|
||||
});
|
||||
}
|
||||
|
||||
load() {
|
||||
if (this.optionsService.options.disableLazySchemas) return;
|
||||
if (this.loaded) return;
|
||||
if (this.pointer) {
|
||||
this.dcl.loadNextToLocation(JsonSchema, this.viewRef).then((compRef) => {
|
||||
this.initComponent(compRef);
|
||||
// trigger change detection
|
||||
if (compRef.changeDetectorRef) {
|
||||
compRef.changeDetectorRef.detectChanges();
|
||||
} else {
|
||||
compRef.hostView.changeDetectorRef.detectChanges();
|
||||
}
|
||||
});
|
||||
this._loadAfterSelf();
|
||||
}
|
||||
this.loaded = true;
|
||||
}
|
||||
|
@ -63,29 +67,13 @@ export class JsonSchemaLazy {
|
|||
// skip caching view with tabs inside (discriminator) as it needs attached controller
|
||||
// FIXME: get rid of dependency on selector
|
||||
if ($element.querySelector('.discriminator-wrap')) {
|
||||
this.dcl.loadNextToLocation(JsonSchema, this.viewRef).then((compRef) => {
|
||||
this.initComponent(compRef);
|
||||
if (compRef.changeDetectorRef) {
|
||||
compRef.changeDetectorRef.detectChanges();
|
||||
} else {
|
||||
compRef.hostView.changeDetectorRef.detectChanges();
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
insertAfter($element.cloneNode(true), this.elementRef.nativeElement);
|
||||
} );
|
||||
});
|
||||
} else {
|
||||
cache[this.pointer] = this.dcl.loadNextToLocation(JsonSchema, this.viewRef).then((compRef) => {
|
||||
this.initComponent(compRef);
|
||||
if (compRef.changeDetectorRef) {
|
||||
compRef.changeDetectorRef.detectChanges();
|
||||
} else {
|
||||
compRef.hostView.changeDetectorRef.detectChanges();
|
||||
}
|
||||
return compRef;
|
||||
});
|
||||
cache[this.pointer] = this._loadAfterSelf();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user