Ensure that we return stable observer references

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2022-09-08 09:20:22 +02:00
parent 0f88eab1b7
commit 8a57ffc0fa
7 changed files with 104 additions and 58 deletions
@@ -27,12 +27,16 @@ import Observable from 'zen-observable';
* @public
*/
export class LocalStoredShortcuts implements ShortcutApi {
constructor(private readonly storageApi: StorageApi) {}
private readonly shortcuts: Observable<Shortcut[]>;
constructor(private readonly storageApi: StorageApi) {
this.shortcuts = Observable.from(
this.storageApi.observe$<Shortcut[]>('items'),
).map(snapshot => snapshot.value ?? []);
}
shortcut$() {
return Observable.from(this.storageApi.observe$<Shortcut[]>('items')).map(
snapshot => snapshot.value ?? [],
);
return this.shortcuts;
}
get() {