Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

91
Views
How to apply filter to pairwise?

I have the stream:

 this.unselectedObjectsIds$ = this.selectedObjectsIds$.pipe(pairwise());

Where this.selectedObjectsIds$ is

[
   ['131086', '131089', '131090', '131638', '132139'], 
   ['131086', '131089']
]

I try to apply this fiilter to the stream:

this.unselectedObjectsIds$ = this.selectedObjectsIds$.pipe(
    pairwise(), 
    map((a) => a[0].filter(x => !a[1].includes(x))
);

Filter is:

a[0].filter(x => !a[1].includes(x));

But it does not work for me.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

pairwise is waiting for the next value

Because you have only one value - it is array: [['131086', '131089', '131090', '131638', '132139'], ['131086', '131089']]

if selectedObjectsIds$ is BehaviorSubject for example

you need send a new value selectedObjectsIds$.next([]) and your code will be paired as

[[['131086', '131089', '131090', '131638', '132139'], ['131086', '131089']], []]

I will try to guess what you are going to have in OUTPUT:

is it ["131090", "131638", "132139"]?

if yes - then use next snippet

import { map, pairwise, take, tap } from 'rxjs/operators';
import { BehaviorSubject, interval, of } from 'rxjs';

const selectedObjectsIds$ = new BehaviorSubject([
  ['131086', '131089', '131090', '131638', '132139'],
  ['131086', '131089'],
]);

const unselectedObjectsIds$ = selectedObjectsIds$.pipe(
  tap((data) => {
    console.log(data);
  }),
  map(([arr1, arr2]) => {
    console.log(arr1);
    console.log(arr2);
    return arr1.filter((x) => !arr2.find((i) => i === x));
  })
);
unselectedObjectsIds$.subscribe((data) => console.log(data));


demo: https://stackblitz.com/edit/typescript-i4nazm?file=index.ts

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!