Answer the question
In order to leave comments, you need to log in
How to make the code more understandable - by separating the logic?
In the parent component in ngOninit (), a request is made to receive data, if the data does not arrive, another request is executed next.
Then I pass the response through rxjs operators to form a specific object.
this.route.params
.pipe(
pluck('num'),
tap((num) => {
this.peonService1.repositoryModel.findallversionbynum.model.num = num;
this.peonService2.repositoryModel.findallversionbynum.model.num = num;
this.peonService3.repositoryModel.findallversionbynum.model.num = num;
}),
switchMap(() =>
parcel.versions.load().pipe(
tap((versions) => parcel.versions.set(versions)),
map(() => parcel),
flatMap((result) => {
return result.versions.exist()
? of(result)
: premisse.versions.load().pipe(
tap((versions) => premisse.versions.set(versions)),
map(() => premisse),
);
}),
),
),
)
.subscribe((parcelOrPremise: RustParcel | RustPremise) => {
console.log(parcelOrPremise);
parcelOrPremise.getByItGeoId();
this.listChangesCad = parcelOrPremise.versions.get();
});
public RustParcel: RustParcel;
public RustPremise: RustPremise;
.subscribe((parcelOrPremise: RustParcel | RustPremise) => {
parcelOrPremise.getByItGeoId();
this.listChangesCad = parcelOrPremise.versions.get();
if (parcelOrPremise instanceof RustParcel) {
this.RustParce = parcelOrPremise;
}
if (parcelOrPremise instanceof RustPremise) {
this.RustPremise = parcelOrPremise;
}
});
<app-RustPremise *ngif="RustPremise"></app-RustPremise>
<app-RustParcel *ngif="RustParcel"></app-RustParcel>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question