angelnikolov / ts-cacheable

Observable/Promise Cache Decorator
https://npmjs.com/package/ts-cacheable
ISC License
340 stars 42 forks source link

Removed shareReplay #49

Closed angelnikolov closed 5 years ago

angelnikolov commented 5 years ago

Fixes #48 There was an unneeded shareReplay operator added to the observable returned by the @Cacheable decorated method which caused other calls to the method to reuse the return value of the previous call, even if it was already unsubscribed for. This was clearly visible when you had multiple routes using async pipes subscribed to cached service methods. Basically, navigating fast through routes, would cause the async pipe to not unsubscribe from the Observable on ngDestroy which caused performance issues. Also, sometimes you could witness stale data due to the same issue. Thanks @DrakeAnglin for reporting!