Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 18:30
    benlesh review_requested #5844
  • 18:30
    benlesh opened #5844
  • 18:26
    yjaaidi opened #5843
  • 14:39
    benlesh synchronize #5842
  • 14:31

    benlesh on master

    Use `unknown` instead of `any` … (compare)

  • 14:31
    benlesh closed #5839
  • 04:32

    cartant on master

    chore: update distinctUntilChan… (compare)

  • 04:32
    cartant closed #5841
  • 04:21

    cartant on master

    chore: update distinct tests to… (compare)

  • 04:21
    cartant closed #5840
  • 01:14
    cartant commented #5839
  • 01:13
    cartant commented #5839
  • 00:51
    benlesh commented #5839
  • Oct 20 22:55

    kolodny on master

    Bind callback ts4 (#5803) * fe… (compare)

  • Oct 20 22:55
    kolodny closed #5803
  • Oct 20 22:50
    kolodny synchronize #5803
  • Oct 20 22:47
    benlesh commented #5831
  • Oct 20 22:46
    benlesh review_requested #5842
  • Oct 20 22:46
    benlesh opened #5842
  • Oct 20 21:08
    cartant commented #5839
Henning Dieterichs
@hediet
I think the conversion rate is much higher if you are already on the blog :D Or don't you think?
I think I'm going to use cookies to store whether it is maximized or not and then automatically scroll down when that cookie is set.
Dallas Cook
@dallasacook
I am running into an issue where a forkJoin containing an Observable made up of multiple Observable's using mergeMap, but the forkJoin never resolves. Does anyone have any idea how else I may be able to handle this?
forkJoin([getUsers$, getOrgs$])
  .subscribe(() => {
    // never gets here
  })
// where
getUsers$: Observable<any> {
  return someObservable$.pipe(
    mergeMap(url) => {
      return this.httpClient.get(url);
    }
  )
}
// assume getOrgs$ resolves properly..
I've also tried to use switchMap as well.
Dallas Cook
@dallasacook
The accepted answer on this StackOverflow post is VERY similar to what I'm currently doing other than using forkJoin
https://stackoverflow.com/questions/49255762/angular5-httpinterceptor-depending-on-the-result-of-an-observable
Henning Dieterichs
@hediet
It should work, as long as httpClient.get, someObservable$, getUsers$ and getOrgs$ yield a value and complete.
Dorus
@Dorus
@dallasacook I would suggest you put a tap on getUsers and getOtrgs and see if they next+complete. If they only complete for example, the forkJoin will complete too but not emit anything (basicly be EMPTY).
knostradamus
@knostradamus
hey all, ngrx question here: why would a property in my state tree be removed by settings it's value to undefined in the reducer?
Derek
@derekkite
dallasacook's problem was that he was using behavior subjects, which don't complete.
Artem Halas
@artem-galas

Hello, everyone!

I would like to contirbute to RxJs, and I know the dtslint test need to be improve.
My simple question - do dtslint test should have tests with Generic?

Another question, but I know it's complicated to find out, but still, what operators is outdated in the dtslint tests? I asume thats some that is not being updated about a year.

Delaney
@delaneyj
Hi everyone, trying to reimplement a backend connection with rxjs and having a hell of a time wrapping my head around the right way to do it
basically I have two major rpc calls ListFoos and FooEvents. I want to continuely call/update ListFoos until a user selects one. Then I want to make repeated calls to FooEvents with an (offset,maxEvents) creating a new stream of events`
the calls to the backend are Promise based and was using asyn/await
Andrew Dzyachko
@A-STAR
@delaneyj too much of stuff timer -> switchMap (ListFoos) -> forJoin (FooEvents[])
Delaney
@delaneyj
yeah, I found out expand is my friend for this
SirFizX
@EricEisaman
Hello RxJS community. How can I best subscribe to observed changes to the length of keys on an object?
Derek
@derekkite
@EricEisaman what are you trying to accomplish?
SirFizX
@EricEisaman
Hello @derekkite and thank you for replying. I wish to observe a state object for current users from an admin dashboard. I need only check for top level changes to the object in question so deep recursion is not required. I have developed a simple Proxy based solution but wish to integrate RxJS into my workflow soon, particularly for the functional operators.
Dorus
@Dorus
@EricEisaman RxJs itself doesn't detect object changes, but if you have an object that emit on change, you can create an observable out of those events and subscribe to that.
There are many libraries that support object change detection, angular for example does.
But a simple get/set method in TS works too.
SirFizX
@EricEisaman
@derekkite Thanks. I may define an on change event for my state object and use the fromEvent API.
Derek
@derekkite
@EricEisaman you likely are getting the list of users via an api call of some kind. Is it an observable or promise? There is an operator that watches for changes, let me look it up. then you can map the value to what you need
distinctUntilChange, or filter to do your own check
Dorus
@Dorus
Yes you can also directly bind the http call to an observable. Or even an websocket etc.
SirFizX
@EricEisaman
@derekkite It is a socketio msg event API.
Dorus
@Dorus
You can use the RxJs fromEvent directly on the socketio i think. No experience with it but a quick google gave me some promising results.
Derek
@derekkite
@EricEisaman yes. that can be wrapped in an observable if it isn't already, then distinctUntilChange.
SirFizX
@EricEisaman
@Dorus @derekkite Thank you for your guidance. Have a great day.
Dorus
@Dorus
Good luck :)
DrewMoody
@DrewMoody
I have two streams (A, B) I want to combine. The second stream (B) uses a result from the first stream (A) for calculations. So I need A to complete before B runs. I don't want the combined stream to emit until both have completed. Is there a creation obs to handle this? Or best to A.pipe -> switchMap to B -> map both together?
Jorrit
@jorrit-wehelp
yeah, you need switchMap
you need an emitted vaue from A to B, so if you somehow really want to wait for completion, you'd pipe on a takeLast(1) onto stream A
DrewMoody
@DrewMoody
Got it. That makes sense, thanks a lot
DrewMoody
@DrewMoody
Just curious -- Is there a way to access the original value on the chain after you use switchMap? This is how I handled:
            switchMap((A) =>
                B.pipe(
                    map((B) => ({
                        A,
                        B: { ...B, calcVal: ((A.prop / B.prop) * 100).toFixed(1) }
                    }))
                )
            ),
(by nesting) -- just wondering if there's a way to do that mapping on the original chain
Jorrit
@jorrit-wehelp
yep, an inner map is the way to handle that
and no other way, well, without writing your own operator ;p
DrewMoody
@DrewMoody
Ohh haha ok, thanks again!
DrewMoody
@DrewMoody
Another quick question -- if I have a subject (a state subject, for example) should I be completing and/or unsubscribing from it directly when I want to destroy it? Or is unsubbing all subscribers sufficient?
Dorus
@Dorus
@DrewMoody There used to be resultSelectors on most operators like switchMap(a => b, (a,b) => ...) but they've all been removed to reduce the size of the library. Using inner maps like you did is actucally what you find back in the migration guide too.

Another quick question -- if I have a subject (a state subject, for example) should I be completing and/or unsubscribing from it directly when I want to destroy it? Or is unsubbing all subscribers sufficient?

Unsubscribe and complete have different effects. Compete would terminate all other subscribers too, but if your subscribers have inner streams (like inside a switchMap), those might keep going for a bit longer.
There is also a third option to use takeUntil to unsubscribe.

and/or

No need to do both. Either complete it to let it shut down gracefully or unsubscribe to put an instant stop to the stream. (It wont terminate anything, but operators will no longer call their followup, ignoring a few exceptions like finalize). (Doing both wont harm but it's not needed either.)

@DrewMoody
This message was deleted
DrewMoody
@DrewMoody
Oh, good to know about the migration guide. Also thanks a lot for the explanation on unsubscribing & completing, have been curious for a while so it's nice to get a concrete answer. I have tended to be overcautious to make sure I don't inadvertently create a leak
Dorus
@Dorus
Yeah, if you know exactly what you're doing you can get rid of a few unsubscribe/complete calls, but generally it's a good idea to err on the side of caution with those things. You make it so much easier for yourself later on too :)
Renke Grunwald
@renke
I want to subscribe to multiple observable at the same time but let them emit in order (say from left to right), a bit like merge(first$, second$) but don't let second$ emit until first$ completes. Any idea how to do this?
Dorus
@Dorus
yeah, concat to start.
Renke Grunwald
@renke
with concat, second$ is subscribed to only after first$ completes, right?