Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Nov 25 14:05
    wSedlacek edited #6689
  • Nov 25 14:03
    wSedlacek opened #6689
  • Nov 25 09:11
    matthewjh commented #6674
  • Nov 24 17:08
    kwonoj closed #6688
  • Nov 24 16:35
    jakovljevic-mladen commented #6688
  • Nov 24 16:01
    fabioemoutinho opened #6688
  • Nov 23 11:41
    cartant commented #6682
  • Nov 23 09:13
    jakovljevic-mladen opened #6687
  • Nov 23 08:26
    jakovljevic-mladen commented #6683
  • Nov 22 15:41
    abelardolg opened #6683
  • Nov 22 15:35
    voliva edited #6682
  • Nov 22 15:32
    voliva edited #6682
  • Nov 22 15:28
    voliva opened #6682
  • Nov 21 13:34
    benjamingr commented #6675
  • Nov 19 19:41

    benlesh on testing-github

    (compare)

  • Nov 19 19:39
    benlesh closed #6680
  • Nov 19 19:34
    benlesh opened #6680
  • Nov 19 19:34

    benlesh on testing-github

    chore: Just testing Github. (compare)

  • Nov 19 19:33

    benlesh on testing-github

    (compare)

  • Nov 19 10:45
    demensky commented #6640
Dorus
@Dorus

like this

but i'm not too attached so any notice or none works for me.

I like to keep the Erik Meijer tweet at least.
Henning Dieterichs
@hediet
yeah no problem
Hmm, the need to scroll down every time the playground is opened via a link annoys me... I have a standalone version of the playground though. However, I wanted to push my (brand new) blog with this playground...
Dorus
@Dorus
haha
Why not link to your blog from the playground instead?
There is plenty of room for things like that on the top bar.
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.)