From c7d770bbe37149f538d5eedc76197ce3b0bc9bec Mon Sep 17 00:00:00 2001 From: squidfunk Date: Sat, 22 Aug 2020 18:03:47 +0200 Subject: [PATCH] Refactored other browser observables, removed memleaks --- src/assets/javascripts/browser/location/base/index.ts | 2 +- src/assets/javascripts/browser/media/index.ts | 2 +- src/assets/javascripts/browser/viewport/_/index.ts | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/assets/javascripts/browser/location/base/index.ts b/src/assets/javascripts/browser/location/base/index.ts index 67ac66e63..ccd9176a0 100644 --- a/src/assets/javascripts/browser/location/base/index.ts +++ b/src/assets/javascripts/browser/location/base/index.ts @@ -51,6 +51,6 @@ export function watchLocationBase( .toString() .replace(/\/$/, "") ), - shareReplay(1) + shareReplay({ bufferSize: 1, refCount: true }) ) } diff --git a/src/assets/javascripts/browser/media/index.ts b/src/assets/javascripts/browser/media/index.ts index 045b54395..b7712c793 100644 --- a/src/assets/javascripts/browser/media/index.ts +++ b/src/assets/javascripts/browser/media/index.ts @@ -41,6 +41,6 @@ export function watchMedia(query: string): Observable { ) .pipe( startWith(media.matches), - shareReplay(1) + shareReplay({ bufferSize: 1, refCount: true }) ) } diff --git a/src/assets/javascripts/browser/viewport/_/index.ts b/src/assets/javascripts/browser/viewport/_/index.ts index c918bc5ef..6e8d7ed6a 100644 --- a/src/assets/javascripts/browser/viewport/_/index.ts +++ b/src/assets/javascripts/browser/viewport/_/index.ts @@ -78,7 +78,7 @@ export function watchViewport(): Observable { ]) .pipe( map(([offset, size]) => ({ offset, size })), - shareReplay(1) + shareReplay({ bufferSize: 1, refCount: true }) ) } @@ -116,7 +116,6 @@ export function watchViewportAt( y: offset.y - y + height }, size - })), - shareReplay(1) + })) ) }