Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 13:35
    huan commented #6669
  • 13:29
    huan synchronize #6669
  • 11:18
    jakovljevic-mladen converted_to_draft #6678
  • Dec 01 21:25
    benlesh unlabeled #6696
  • Dec 01 21:25
    benlesh commented #6696
  • Dec 01 19:06

    kwonoj on master

    chore(issue): update issue temp… chore: Use Stackblitz rxjs temp… chore: Tweak label to be more c… and 4 more (compare)

  • Dec 01 19:06
    kwonoj closed #6668
  • Dec 01 19:05
    kwonoj closed #6698
  • Dec 01 19:05
    kwonoj locked #6698
  • Dec 01 19:05
    ronag edited #6698
  • Dec 01 19:05
    ronag edited #6698
  • Dec 01 19:04
    ronag commented #6698
  • Dec 01 19:04
    ronag opened #6698
  • Nov 30 21:41
    driskell commented #6696
  • Nov 30 20:52
    josepot commented #6690
  • Nov 30 20:51
    josepot commented #6690
  • Nov 30 19:33
    jakovljevic-mladen commented #6678
  • Nov 30 19:23
    benlesh commented #6678
  • Nov 30 19:22
    benlesh commented #6678
  • Nov 30 19:15
    benlesh synchronize #6696
lake-toya
@lake-toya
maybe queue is the wrong term here :D
Jorrit
@jorrit-wehelp
yeah and introducing your own schedule concept is confusing, since rxjs already has its own schedulars :p
But if you get them one at a time (so the 'queue' is in the database I guess), can't you use a repeat() to resubscribe to the db get action after the job has been processed
lake-toya
@lake-toya
oh right, that would be an easy way to do it ... haha thanks
jcapil-ictdu
@jcapil-ictdu
Hello all, any resources for reactjs for beginner. thank you.
Dorus
@Dorus
@jcapil-ictdu wrong channel
bitQ2019
@bitQ2019
hello
PikaChokeMe
@PikaChokeMe
I have an array of Observable<httpData>...
Basicaly Observable<httpData>[]
how do I turn this into an Observable<httpData[]> ?
PikaChokeMe
@PikaChokeMe

I tried to say

    return of(this.jenkinsService.getArrayOfHttpData())
      .pipe(
        mergeMap((observableArray: Observable<httpData>[]) => {
          return forkJoin(...(observableArray.map((observableItem: Observable<httpData>) =>
            observableItem
          )));
        })
      );
  }

But I have like no idea what I'm doing :l

matrixbot
@matrixbot
elpdpt Ryan (Gitter): Not sure I understand your edit becuase its the same, but your solution is right for what you said first. You can simplify it also
return of(this.jenkinsService.getArrayOfHttpData())
  .pipe(
    switchMap(dataObservablesList => forkJoin(...dataObservablesList))
  );
elpdpt * Ryan (Gitter): Your solution is right for what you said first. You can simplify it also
return of(this.jenkinsService.getArrayOfHttpData())
  .pipe(
    switchMap(dataObservablesList => forkJoin(...dataObservablesList))
  );
Dorus
@Dorus
@TheeRFG Try from(arr).pipe(mergeAll())
That will make it emit all httpData's seperate. You could then add a toArray() at the end to change it to Observabel<httpData[]>, but i would probably suggest against that, the idea of RxJs is that you process async streams and handle the results as they come in, not delay till all results are ready.
StephenS
@S-Stephen

Hi, Is someone able to help me figure out what operator(s) I should be using?
I have two observables obs1 and obs2, and I want to combine their latest results only when Obs2 changes something like:

Obs1>----A----B---C----D----E-----
Obs2>--F--------------G---------H--
Out_>-----AF---------CG--------EH

What operator(s) should I use? I've considered using combineLatest, storing the last value of Obs2, and if changes emit the two values, but is this the best approach? (it doesn't feel right using a ?side effect? to track the state) and what operator should I used to 'emit' the combined values?

matrixbot
@matrixbot
elpdpt StephenS (Gitter): It seems you can use distinctUntlChanged with custom compareFunction, checking for the first value in the array for distinction.
distinctUntilChanged((a, b) => a[0] !== b[0])
Dorus
@Dorus
@S-Stephen look at withLatestFrom
looks like
Out_ = Obs2.pipe(withLatestFrom(Obs1))
StephenS
@S-Stephen
@matrixbot @Dorus thanks both. it looks as though withLatestFrom fits the bill
Arun Gopalpuri
@arun0009
How do I forkJoin an observable of array? Do i have to convert it into an array of observable?
matrixbot
@matrixbot
elpdpt Arun Gopalpuri (Gitter): Not sure what you mean. Is the original array contains processes (observables/promises) or just values?
Arun Gopalpuri
@arun0009
@matrixbot - Okay, let me try to explain what I'm trying to do, I have a promise of users, for each user I want to get its promise(accounts), and for each account, I want to get its promise(details). I was thinking of collecting all users in an array and get accounts in parallel using forkJoin and similarly details in parallel using forkJoin.
matrixbot
@matrixbot
elpdpt @aru

elpdpt Arun Gopalpuri (Gitter): you could do that nesting of forkjoin and switchmaping.
For me its easier to have more flat liner of stream so maybe take each array emission and emit each item in the array would be easier to reason about.

Something like this:

getUsers$().pipe(
  mergeMap(users => from(users, asyncScheduler)),
  mergeMap(user => getUserAccounts(user)),
  mergeMap(accounts => from(accounts, asyncScheduler)),
  mergeMap(account => getAccountDetails(account)),
)
Arun Gopalpuri
@arun0009
@matrixbot Thanks for the clean approach with the example. I also tried to apply this same pattern but I ended up in nested pipes as I have to pass values downstream to other observables. Is there a better way of doing this? e.g.
export const getRegionClusterDetailsObservable = (region: string, ecs: AWS.ECS, elb: AWS.ELBv2, clusterPrefixes: string[]) => {
    return clusterArnsObservable(ecs, clusterPrefixes)
        .pipe(mergeMap(clusterArn => ecsListServicesObservable(ecs, clusterArn)
            .pipe(mergeMap(ecsServices => describeECSServicesObservable(ecs, ecsServices.serviceArns, clusterArn)
                .pipe(mergeMap(describeECSServicesResponse => from(describeECSServicesResponse.services)
                    .pipe(mergeMap(service => describeELBTargetHealthObservable(elb, service)
                        .pipe(mergeMap(targetHealthResponse => describeTaskDefinitionObservable(ecs, service)
                            .pipe(mergeMap(taskDefResponse => of(createClusterDetails(region, service, clusterArn, taskDefResponse, targetHealthResponse))))))))))))))
}
Bala_github
@GitHubBala23
Hi All, I am new to RxJs in Angular. And I was facing an issue while transferring data from 1 component to another. I am using a Subject in service file nd using that I m sending data user clicks on screen to another component nd display the component where data was transferred. But on the 1st load no data is transferred even though the component loads on the page
Dorus
@Dorus
@arun0009 Well the last mergeMap(e => of(e)) could just be map(e => e)
For the ones before, it's harder, you could do mergemap(e => call(e).pipe(map(r => ({...e, r})))) each time to add the new value to it.
1 reply
@GitHubBala23 you need to subscribe to a subject before you send data to it. Probably you generate the second component after the click has already been made.
Dominic Watson
@intellix
having a really weird issue using withLatestFrom() where it can't get past it
I have a source and these in the pipe:
tap(() => console.log(1)),
withLatestFrom(brandGames$.pipe(tap(() => console.log(2)))),
tap(() => console.log(3)),
it emits 1, 2........ but then doesn't emit 3 until later or not at all. I don't have any catchErrors swallowing errors

if I replace that brandGames$.pipe with this:

withLatestFrom(of([])),

then it emits

this is also problematic it seems:
withLatestFrom(timer(4000)),
Dominic Watson
@intellix
ok so it seems if the withLatestFrom contains a source that hasn't emitted yet, it never gets past it
Dorus
@Dorus
@intellix yes correct, both sides need to emit before it works, and the inner observable needs to emit first. You can use strartWith to make sure there is an initial value.
typogod
@typogod
Is there a switch operator? Not switchMap, just switch.
Dorus
@Dorus
@typogod I dont understand what you're asking for
Jorrit
@jorrit-wehelp
switchMap without the Map? I'd say that is just a .map(x -> ...switch logic...) :)
typogod
@typogod
like observable.pipe(switch())
Dorus
@Dorus
@typogod I still dont understand what you're expecting
can you draw up a marble diagram of expected in and output?
typogod
@typogod
D'oh, I found it. switchAll(). Sorry for being thickheaded. :D
Dorus
@Dorus
switchAll() is just switchMap(e => e) :)
Also switchMap(selector) is pipe(map(selector), switchAll())
typogod
@typogod
I'm writing a library which is trying to follow RxJS fairly closely in terms of API and naming.
So that it will be interchangable for most people.
Dorus
@Dorus
Interesting
typogod
@typogod
I'm a big fan of the RxJS API. But I need to use iterators instead of observables, so I'm doing this.
Dorus
@Dorus
@typogod is it still async?
Or do you just run it on plain iterators? Do you know https://github.com/ReactiveX/IxJS ?
Actually that project has asyncIterator too.