From 814716cc8dd3f877730537adb43e9cf68a880f7b Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Mon, 30 Apr 2018 17:20:20 -0700 Subject: [PATCH] remove deprecated observe() from stores, take 2 (#249) --- routes/_components/virtualList/virtualListStore.js | 13 +++++++------ routes/_store/store.js | 3 +++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/routes/_components/virtualList/virtualListStore.js b/routes/_components/virtualList/virtualListStore.js index c9670e9..8faf521 100644 --- a/routes/_components/virtualList/virtualListStore.js +++ b/routes/_components/virtualList/virtualListStore.js @@ -104,12 +104,13 @@ virtualListStore.compute('allVisibleItemsHaveHeight', if (process.browser && process.env.NODE_ENV !== 'production') { window.virtualListStore = virtualListStore - virtualListStore.observe('visibleItems', () => { - window.visibleItemsChangedCount = (window.visibleItemsChangedCount || 0) + 1 - }) - - virtualListStore.observe('rawVisibleItems', () => { - window.rawVisibleItemsChangedCount = (window.rawVisibleItemsChangedCount || 0) + 1 + virtualListStore.on('state', ({changed}) => { + if (changed.visibleItems) { + window.visibleItemsChangedCount = (window.visibleItemsChangedCount || 0) + 1 + } + if (changed.rawVisibleItems) { + window.rawVisibleItemsChangedCount = (window.rawVisibleItemsChangedCount || 0) + 1 + } }) } diff --git a/routes/_store/store.js b/routes/_store/store.js index ffaa7a9..2842c2f 100644 --- a/routes/_store/store.js +++ b/routes/_store/store.js @@ -2,6 +2,7 @@ import { observers } from './observers/observers' import { computations } from './computations/computations' import { mixins } from './mixins/mixins' import { LocalStorageStore } from './LocalStorageStore' +import { observe } from 'svelte-extras' const KEYS_TO_STORE_IN_LOCAL_STORAGE = new Set([ 'currentInstance', @@ -24,6 +25,8 @@ class PinaforeStore extends LocalStorageStore { } } +PinaforeStore.prototype.observe = observe + export const store = new PinaforeStore({ instanceNameInSearch: '', queryInSearch: '',