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

276
Views
How to get arguments in a flat way with withLatestFrom in rxjs?

Is it possible to get the arguments of tap function not nested? like some of those ways:

tap(([foo, bar, baz]) => {

or:
tap((foo, bar, baz) => {

or:
tap(({foo, bar, baz}) => {

Because I using withLatestFrom which give me array and I pass an object into Subject so I wondering if its possible to get the arguments in flat way?

stackblitz

import { of, map, Observable, Subject, tap } from 'rxjs';
import { withLatestFrom } from 'rxjs/operators';

const action = new Subject<{ foo: number; bar: number }>();

const baz$ = of(3);

const op = action.pipe(
  withLatestFrom(baz$),
  tap(([{ foo, bar }, baz]) => {
    console.log({ foo, bar, baz });
  })
);

op.subscribe();

action.next({ foo: 1, bar: 2 });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can create a custom operator to flatten object to array

const transformToArray = source=>source.pipe(map((values:any)=>{
  return values.map(v=>v instanceof Object?Object.values(v):v).flat()
}
))
const op = action.pipe(
  withLatestFrom(baz$),
  transformToArray
);
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!