DEV Community

Discussion on: HOWTO: Create a cool animated button for API calls!

Collapse
 
avogadrosg1 profile image
AvogadroSG1 • Edited

As an update to this post, I recognized that in the tap() the complete: function can't be guaranteed to run for many different reasons. See the RxJS docs for the information on error and how to handle them asynchronously.

github.com/Reactive-Extensions/RxJ...

I decided to change the code for action button to use the finalize instead since we always want the function to reset the button state.

      finalize(() => {
          setTimeout(
            () => {
              this.status = null as any;
            },
            this.status === Result.SUCCESS ? 2000 : 3000
          );
        })
Enter fullscreen mode Exit fullscreen mode