Make handleStorageChange method in WebStorage class private
Signed-off-by: Dawit Ameneshewa <dawitam11@gmail.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user