Skip to content
Advertisement

Tag: promise

When should I use try catch instead of then catch?

The question is simple, but I haven’t found the answer anywhere. When should i use try catch? in the code below I use try catch to handle the return of a request: Would it be a good practice to use then(…).catch(…)? Answer The difference is in how you’re handing Promises. If you’re using await to handle the Promise then you

Alternatives to Deferred (anti?-)pattern when awaiting for user interactions in Angular

I’m building a game using Angular which has the following mechanics: An Angular service checks the game state and requests a required user interaction. A mediator service creates this request and emits it to the relevant Angular component using a RxJS subject. A response to this request is awaited in this mediator service, game doesn’t go on until request is

Managing promises in RXJS observables

I’ve poked about SO and found many similar questions/answers but I may be missing something in my basic understanding on how to work with with this stack. I’m working on a react native project along with RXJS/obervables. At some point I doing file downloads, this part is not a problem. A combo of pre-existing axios-rxjs and react-native-file-system get me where

.toPromise() and lastValueFrom() in rxjs

I have this observable I call it with .toPromise() is deprecated, so I would like to change the call with lastValueFrom(): but I receive the following error: UPDATE: for now, resolved with: but is there a better solution? Answer Is there a better solution? Yes and no. In your case mergeMap(_ => EMPTY) will ensure that your observable completes without

Advertisement