diff --git a/.changeset/wild-pears-enjoy.md b/.changeset/wild-pears-enjoy.md index 8cee4daa54..01a8b8a4a1 100644 --- a/.changeset/wild-pears-enjoy.md +++ b/.changeset/wild-pears-enjoy.md @@ -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 diff --git a/packages/core-app-api/api-report.md b/packages/core-app-api/api-report.md index 54aa700472..70312a54a5 100644 --- a/packages/core-app-api/api-report.md +++ b/packages/core-app-api/api-report.md @@ -558,8 +558,6 @@ export class WebStorage implements StorageApi { // (undocumented) get(key: string): T | undefined; // (undocumented) - handleStorageChange(eventKey: StorageEvent['key']): void; - // (undocumented) observe$( key: string, ): Observable>; diff --git a/packages/core-app-api/src/apis/implementations/StorageApi/WebStorage.ts b/packages/core-app-api/src/apis/implementations/StorageApi/WebStorage.ts index 224327298f..3477853241 100644 --- a/packages/core-app-api/src/apis/implementations/StorageApi/WebStorage.ts +++ b/packages/core-app-api/src/apis/implementations/StorageApi/WebStorage.ts @@ -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$( key: string, ): Observable> { - 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); diff --git a/packages/core-plugin-api/api-report.md b/packages/core-plugin-api/api-report.md index ed40792c6a..cebf09e908 100644 --- a/packages/core-plugin-api/api-report.md +++ b/packages/core-plugin-api/api-report.md @@ -697,7 +697,6 @@ export type SignInPageProps = { // @public export interface StorageApi { forBucket(name: string): StorageApi; - handleStorageChange?(eventKey: StorageEvent['key']): void; observe$( key: string, ): Observable>; diff --git a/packages/core-plugin-api/src/apis/definitions/StorageApi.ts b/packages/core-plugin-api/src/apis/definitions/StorageApi.ts index 5ecf251e2d..1506e5f143 100644 --- a/packages/core-plugin-api/src/apis/definitions/StorageApi.ts +++ b/packages/core-plugin-api/src/apis/definitions/StorageApi.ts @@ -85,14 +85,6 @@ export interface StorageApi { key: string, ): Observable>; - /** - * 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. *