Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between finally and finalize in rxjs

Tags:

angular

rxjs

I am using RxJS and I can see there are 2 function in RxJS 5.5.2 available. Is the .finally will be removed and it will be placed in side pipe() from RxJS 6.0.0 on wards is the reason or there are any other changes?

Are they both same and now final call is inside pipe()?

Or they have any notable difference?

finalize

method()
   .pipe(
     finalize(() => {
      // do some operation
     })
   )

finally

method()
  .finally(() => {
    // do your operation
  })
like image 335
Aniruddha Das Avatar asked May 10 '18 15:05

Aniruddha Das


1 Answers

Both are same functionality wise both does same operation of calling once observable is completed but difference is which version of rxjs you are using

Before v5.5 it is been called as finally

From v5.5 it is renamed to finalize(due to keyword restriction), because of the introduction to pipeable Operators which helps better tree shaking. For more info please check this link

like image 62
Abinesh Devadas Avatar answered Nov 15 '22 22:11

Abinesh Devadas