Make handleStorageChange method in WebStorage class private

Signed-off-by: Dawit Ameneshewa <dawitam11@gmail.com>
This commit is contained in:
Dawit Ameneshewa
2022-12-07 16:45:32 +03:00
parent 5aa0dc604f
commit 1dec14de93
5 changed files with 5 additions and 16 deletions
+1 -1
View File
@@ -2,4 +2,4 @@
'@backstage/core-app-api': patch
---
Made `StorageApi` notify its subscribers when `localStorage` values change in other tabs/windows
Made `WebStorage` notify its subscribers when `localStorage` values change in other tabs/windows
-2
View File
@@ -558,8 +558,6 @@ export class WebStorage implements StorageApi {
// (undocumented)
get<T>(key: string): T | undefined;
// (undocumented)
handleStorageChange(eventKey: StorageEvent['key']): void;
// (undocumented)
observe$<T extends JsonValue>(
key: string,
): Observable<StorageValueSnapshot<T>>;
@@ -35,7 +35,7 @@ export class WebStorage implements StorageApi {
private readonly errorApi: ErrorApi,
) {}
private static hasSubscribers = false;
private static hasSubscribed = false;
static create(options: {
errorApi: ErrorApi;
@@ -101,14 +101,14 @@ export class WebStorage implements StorageApi {
observe$<T extends JsonValue>(
key: string,
): Observable<StorageValueSnapshot<T>> {
if (!WebStorage.hasSubscribers) {
if (!WebStorage.hasSubscribed) {
WebStorage.addStorageEventListener();
WebStorage.hasSubscribers = true;
WebStorage.hasSubscribed = true;
}
return this.observable.filter(({ key: messageKey }) => messageKey === key);
}
handleStorageChange(eventKey: StorageEvent['key']) {
private handleStorageChange(eventKey: StorageEvent['key']) {
if (!eventKey?.startsWith(this.namespace)) return;
const key = eventKey?.replace(`${this.namespace}/`, '');
this.notifyChanges(key);
-1
View File
@@ -697,7 +697,6 @@ export type SignInPageProps = {
// @public
export interface StorageApi {
forBucket(name: string): StorageApi;
handleStorageChange?(eventKey: StorageEvent['key']): void;
observe$<T extends JsonValue>(
key: string,
): Observable<StorageValueSnapshot<T>>;
@@ -85,14 +85,6 @@ export interface StorageApi {
key: string,
): Observable<StorageValueSnapshot<T>>;
/**
* Synchronizes stored data across multiple tabs or windows by using the
* browser's StorageEvent API.
*
* @param eventKey - The key of a storage event object
*/
handleStorageChange?(eventKey: StorageEvent['key']): void;
/**
* Returns an immediate snapshot value for the given key, if possible.
*