benlesh on master
feat: add (optional) defaultVal… (compare)
benlesh on master
docs: Add more detail to deprec… (compare)
benlesh on master
refactor: separate fromEvent si… (compare)
benlesh on master
fix(symbol): revert unique symb… (compare)
benlesh on master
fix: forkJoin/combineLatest ret… (compare)
take
, takeUntil
etc. to finish the subscription at one point.
takeUntil
is NOT the last operator.
Parent Component Contract:
- Child Component Contract Details
- Child component Beds details
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>
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