Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 02:08
    cartant commented #5181
  • Dec 13 21:44
    lock[bot] locked #5130
  • Dec 13 21:30
    kwonoj commented #5181
  • Dec 13 21:30
    kwonoj closed #5181
  • Dec 13 21:30
    kwonoj commented #5181
  • Dec 13 21:24
    fireflysemantics opened #5181
  • Dec 12 19:11
    lock[bot] locked #5101
  • Dec 12 18:16
    lock[bot] locked #5140
  • Dec 12 18:16
    lock[bot] locked #5099
  • Dec 12 18:16
    lock[bot] locked #5129
  • Dec 12 18:09
    lock[bot] locked #5045
  • Dec 12 18:09
    lock[bot] locked #5134
  • Dec 12 18:09
    lock[bot] locked #5137
  • Dec 12 18:09
    lock[bot] locked #5136
  • Dec 12 18:09
    lock[bot] locked #5135
  • Dec 12 18:09
    lock[bot] locked #5121
  • Dec 12 18:09
    lock[bot] locked #5089
  • Dec 12 18:09
    lock[bot] locked #4984
  • Dec 12 16:14
    lock[bot] locked #5095
  • Dec 12 16:14
    lock[bot] locked #5141
Dorus
@Dorus
Mmm 500 error should be async...
Alessandro Tagliapietra
@alex88
yeah
that's why
Dorus
@Dorus
Very weird, but i cannot reproduce it here (have no angular running right now)
Alessandro Tagliapietra
@alex88
sure no worries, thanks a lot for helping!
Alessandro Tagliapietra
@alex88
even adding pipe(catchError) right after the api calls (within flatMap) doesn't log anything :/
Alessandro Tagliapietra
@alex88
an error on the requestA so the main one instead correctly works
Alessandro Tagliapietra
@alex88
damn it
I had an interceptor that returned errors as of(err), I just don't see how that could not work only for nested requests
if all the requests have the same problem
or even better, if it's caught, why subscribe didn't get a success value?
Tim Rose
@timrosede
I want to call a rest service, the rest service gives me a list in that list are
IDS with these ids I need to call another service and manipulate the data of the first request with these. I would like to do this in an Observable. Does anyone have a tip?
return this.systemInformationService.login(username, password)
      .pipe(
        tap((result: SystemInformation) => {

          result.systemInformation.forEach((system) => {
            system.errors.forEach((error: ResponseError) => {
              errors.push(error.message)
            });
          });

          if (errors.length !== 0) {
            throw new Error(errors.join(','));
          }

          result.systemInformation.forEach(system => {
            dispatch(new SystemAccessAction.LoadSystemId(system.webServerUrl)).toPromise();
          });
          patchState(result);
        }),
      );
  }
Dorus
@Dorus
@alex88 So you fixed it?
next time use throwError(err) :D
@timrosede Sounds like you want to do
getList().pipe(
  mergeAll(),
  mergeMap(id => another().pipe(
    map(oth => manipulate(oth, id))
  ))
)
Dorus
@Dorus
getList here get an array of id's.
mergeAll seperates the array into individual id's.
mergeMap does some action for each id. Namely call another()
map will manipuate the id and the result of another with the manipulate method.
Nico
@ndcunningham
@ndcunningham You can concat EMPTY.pipe(delay(n)) to delay just the complete event.
@Dorus where?
  myFun(arg) {
    if (!active) {
      active = true;
      this.result$ = of(arg).pipe(
        mergeMap((e = doCalc(e))),
        tap(() => console.log("i get called every time")),
        finalize(() => {
          active = false;
        }),
        shareReplay()
      );
    }
    return result$;
  }
Dorus
@Dorus

@ndcunningham before the finalize so you delay the complete message, and with that the finalize.

The finalize itself however, will always be async.

Martin Sikora
@martinsik
That's not true. delay delays only next notification, not complete notifications
Dorus
@Dorus
Since you want to build in an animation, you might also make an observable that handles the animation, completes once that is done, and concat that one. You can still use finalize to remove the rendering in case the observable unsubscribes/errors.
@martinsik Really?
Let me test that
@martinsik works for me
Martin Sikora
@martinsik
@Dorus Yes, this behavior will change however ReactiveX/rxjs#4444
Dorus
@Dorus
@martinsik How would you then delay complete? of(1).pipe(delay(n), ignoreElements())?
That's a mouthfull.
Dorus
@Dorus
Ah indeed, concat of(1)+delay+ignoreElements. Will that operator name it into the standard lib?
If i have to redirect people to custom libraries, i rather just use the default operators i think :)
Martin Sikora
@martinsik
Delay now delays complete only if there's no next notifications
It was a bit confusing so that's why there's an open PR to fix that.
Nico
@ndcunningham
Since you want to build in an animation, you might also make an observable that handles the animation, completes once that is done, and concat that one. You can still use finalize to remove the rendering in case the observable unsubscribes/errors.
Dorus
@Dorus
Yeah the fix totally makes sense. I'm just thinking about those special cases where you do want to delay complete.
Nico
@ndcunningham
it's built already if i can i don't want to rewrite everything in RxJs
if i use @martinsik i think other devs will be confused 🤷‍♂️ 😕
Martin Sikora
@martinsik
yes, I know that the solution I use is very confusing to anyone who doesn't understand RxJS very well :).
Nico
@ndcunningham
but thanks for reaching out @martinsik i would've never known that
i understood it after the post i read from @benlesh
because i did try and add a delay lol before asking
clintsinger
@clintsinger
I have a set of operations that I send to a pipe that I need to use in a couple places. Rather than repeating myself is there a way that I can put them into a function that i can pass to the different pipes? For example, the pattern I have looks like the following with the code being the same each place I need to use it.
map(p => { ... }),
tap(p => { ... }),
finalize(() => ...)
Derek
@derekkite
@clintsinger
function myObservableChain(arg) {
       return of(arg)
       .pipe (
           map(p => ...
then call it with mergeMap(v => myObservableChain(v))
or any of the concat, merge, forkjoins or whatever you pass an observable to
clintsinger
@clintsinger
@derekkite Thanks, I'll give it a try.
Dorus
@Dorus

@clintsinger Yeah you can do

myOp() {
  return (source) => source.pipe(
    map(p => { ... }),
    tap(p => { ... }),
    finalize(() => ...)
  )
}

Use is like this source.pipe(myOp())

It'll be a pipable operators just like everything else.
In fact, type of myOp will be OperatorFunction