Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

96
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda