this.wrcService.getWrcBedsByFilter().pipe(map(beds => beds.map(...)))
should be enough right?
//set id if present
this.route.queryParams
.pipe(
map(param => param['id'])
)
.subscribe(paramValue => {
this.contractId = paramValue;
});
The same way I need to check for applicationId
var idQueryParamObs = this.route.queryParams
.pipe(
filter(param => param['id'] != null),
map(param => param['id'])
);
var applicationIdQueryParamObs = this.route.queryParams
.pipe(
filter(param => param[applicationId'] != null),
map(param => param['applicationId'])
);
Connecting to dev server
at the bottom after I hit Run this project button.
ngOnInit() {
this.id$ = this.route.queryParams.pipe(map(params => params.id)); //<---- why no filter here
this.applicationId$ = this.route.queryParams.pipe(
filter(params => !!params.appId), //<----- but here any intended purpose of this?
map(params => params.appId)
);
const combinedIds$ = combineLatest([
this.id$.pipe(filter((id: string) => id !== null)), // and then here
this.applicationId$.pipe(
filter((applicationId: string) => applicationId !== null)
)
]);
this.result$ = combinedIds$.pipe(
map(([id, applicationId]: [string, string]) => ({
id,
applicationId
}))
);
this.result$.subscribe(result => {
console.log({ result });
});
}
}
Project
function it expects. I am never able to implement it.
//set id if present
var idParam = this.route.queryParams
.pipe(
filter(params => !!params.id),
map(params => params.id)
);
var applicationParam = this.route.queryParams
.pipe(
filter(params => !!params.applicationId),
map(params => params.applicationId)
);
const combined = combineLatest([
idParam.pipe(filter((id: string) => id !== null)),
applicationParam.pipe(
filter((applicationId: string) => applicationId !== null)
)
]).pipe(
map(([id, applicationId] : [string, string]) => ({
id,
applicationId
}))
);
var result = combined.pipe(
switchMap(result => {
})
);
result.subscribe((contract: TenantContract) => {
});
I am getting an error in switchMap clause.
this.apiService
.getVigencia()
.pipe(
tap(() => this.getUserSuscriptions()),
filter(res => res.vigenciaIva != true)
)
.subscribe( // do something)
.......
// the function getUserSubcription() is his own best
getUserSuscriptions() {
this.apiService
.getStatus(requestData, this.userRut)
.pipe(
tap(res => {
this.showError =
Array.isArray(res.servicios) && res.servicios.length === 0;
}),
filter(() => this.showError === false)
)
.subscribe(
// process the everything
)
This is legacy code, but i would like to change using concatMap to call in sequence . I having issues with this for some weird cases.
this.apiService.getVigencia().pipe(
mergeMap( data => this.apiService.getStatus( requestData, this.userRut ) )
.pipe(
filter( res => res.vigenciaIva !== true ),
map( res => ( [data, res] )
).subscribe(
finalData => {
console.log(finalData);
},
error => {
this.showError = error
}
);
Hi there, I have this three methods:
getDateRange($event) {
this.dateRange = $event.range;
}
getMembers($event) {
this.highlightMembers = $event.selectedMembers;
}
isChecked($event) {
reurn this.statusSelected.concat(this.prioritySelected)
}
I need to create an array from combination of all of this events, because at last I need to send an eventEmitter that contains this array created dynamically from those events, there is a way to do this with rxjs?
@SAGOlab Although I'd create a type definition for the object:
export interface EmitterType {
range: string; // or number or whatever
selectedMembers: Member[];
isChecked: boolean;
}
...
@Output someEventEmitter: EventEmitter<EmitterType> = new EventEmitter<EmitterType>();
...
someEventEmitter.emit({range: $event.range,
selectedMembers :$event.selectedMembers,
isChecked: this.statusSelected.concat(this.prioritySelected),
});
...assuming I've correctly understood what you're asking.