From adb31ea8d374a3bd0013b007ddc00959d3bad829 Mon Sep 17 00:00:00 2001 From: Ray Schamp Date: Mon, 30 Oct 2017 09:59:19 -0400 Subject: [PATCH] Use a storage singleton This way the instance can be reused, which allows access to non-deprecated `DataFormat` and `AssetType`. --- src/lib/storage.js | 4 +++- src/reducers/vm.js | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib/storage.js b/src/lib/storage.js index e1dc91bd6..d1c8f886d 100644 --- a/src/lib/storage.js +++ b/src/lib/storage.js @@ -26,4 +26,6 @@ class Storage extends ScratchStorage { } } -export default Storage; +const storage = new Storage(); + +export default storage; diff --git a/src/reducers/vm.js b/src/reducers/vm.js index 5d0e6f91f..dd70f3f4f 100644 --- a/src/reducers/vm.js +++ b/src/reducers/vm.js @@ -1,9 +1,9 @@ import VM from 'scratch-vm'; -import Storage from '../lib/storage'; +import storage from '../lib/storage'; const SET_VM = 'scratch-gui/vm/SET_VM'; const defaultVM = new VM(); -defaultVM.attachStorage(new Storage()); +defaultVM.attachStorage(storage); const initialState = defaultVM; const reducer = function (state, action) {