benlesh on 7.0.0-rc.2
benlesh on master
chore(publish): 7.0.0-rc.2 (compare)
benlesh on master
Revert "chore: Add typesVersion… (compare)
Parent Component (TS):
customerInfo$: Subject<CustomerInfo> = new Subject<CustomerInfo>();
//then in a method I am doing the following
private getCustomerInfo() {
var ucid = this.localStorageService.getCompanyUCID();
this.accountService.GetCustomerInfoObservable(ucid)
.subscribe(this.customerInfo$);
// customerInfoObj => {
// this.customerInfo$.next(customerInfoObj);
// });
}
Parent Component (HTML):
<app-contract-general-information
[generalInformationGroup]="contractForm.controls.BasicInformation"
[customerInfoObj]="customerInfo$"
(onNext)="onNext(nav,$event)"
(selectedWrc)="setWrcObject($event)"
></app-contract-general-information>
<app-contract-contrcated-beds
[contractedBedsFormGroup]="contractForm.controls.TenantContractDetails"
[customerInfoObj]="customerInfo$"
(onNext)="onNext(nav,$event)"
[selectedWrc$]="selectedWrc$"
></app-contract-contrcated-beds>
In the child this is how I am consuming:
@Input() customerInfoObj: Subject<CustomerInfo>;
this.customerInfoObj
.subscribe(customerInfo =>{
console.log(customerInfo);
this.wrcList = [...customerInfo.WRC];
})
Same goes for the second component. but nowhere does it works.
wrcList
, I would do something like:this.wrcList$ = this.customerInfoObj.pipe(
tap((customerInfo: customerInfoType) => console.log(customerInfo)), // if you need to log this.
map((customerInfo: customerInfoType) => customerInfo.WRC),
);
CustomerInfo
instead? Or possibly an angular @output EventEmitter
?
takeUtil
with a Subject to manage unsubscribing, do you have to call subject.complete()
? I saw somewhere that you don't, but I am wondering why or why not? Can you explain this or point me to an article that speaks specifically about the complete()
call on that subject and why it would (or wouldn't) be needed?
takeUtil
in fact will unsubscribe upstream and complete downstream.complete
and when it doesn't matter and why. Take a look if interested: https://stackoverflow.com/questions/57007118/do-i-need-to-complete-takeuntil-subject-inside-ngondestroy
this.beds$ = this.wrcService.getWrcBedsByFilter(this.wrcId, workerTypeId, blockId, buildingId, floorId, ['100000002'])
.pipe(
tap(bedsResponse => console.log(bedsResponse)),
filter(bedsResponse => bedsResponse != null),
flatMap(beds => beds),
map(bed => {
bed.numberOfBedsArray = Array.from({length: bed.qty}, (v, i) => i + 1);
return bed;
}),
mergeMap(beds => beds)
);
bedsResponse
is of type Observable<Bed[]>
flatting
it to each Bed object
this.wrcService.getWrcBedsByFilter().pipe(map(beds => beds.map(...)))
should be enough right?