From 4da769c28ea6bc051e16941f1f812d5138e30d2b Mon Sep 17 00:00:00 2001 From: Harry Altman Date: Tue, 9 Apr 2019 20:22:47 -0400 Subject: [PATCH] Remove decodeAll; mark _runSaga as private. --- .../truffle-debugger/lib/data/sagas/index.js | 10 -------- .../truffle-debugger/lib/session/index.js | 24 +++++++++++++++---- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/packages/truffle-debugger/lib/data/sagas/index.js b/packages/truffle-debugger/lib/data/sagas/index.js index 1f6f4e86f08..fc553490ad8 100644 --- a/packages/truffle-debugger/lib/data/sagas/index.js +++ b/packages/truffle-debugger/lib/data/sagas/index.js @@ -81,16 +81,6 @@ export function* decode(definition, ref) { return DecodeUtils.Conversion.cleanContainers(result.value); } -export function* decodeAll() { - let definitions = yield select(data.current.identifiers.definitions); - let refs = yield select(data.current.identifiers.refs); - let decoded = {}; - for (let [identifier, ref] of Object.entries(refs)) { - decoded[identifier] = yield* decode(definitions[identifier], ref); - } - return decoded; -} - function* variablesAndMappingsSaga() { let node = yield select(data.current.node); let scopes = yield select(data.views.scopes.inlined); diff --git a/packages/truffle-debugger/lib/session/index.js b/packages/truffle-debugger/lib/session/index.js index 6317d828caf..6df8afce230 100644 --- a/packages/truffle-debugger/lib/session/index.js +++ b/packages/truffle-debugger/lib/session/index.js @@ -6,7 +6,7 @@ import configureStore from "lib/store"; import * as controller from "lib/controller/actions"; import * as actions from "./actions"; import data from "lib/data/selectors"; -import { decode, decodeAll } from "lib/data/sagas"; +import { decode } from "lib/data/sagas"; import controllerSelector from "lib/controller/selectors"; import rootSaga from "./sagas"; @@ -148,7 +148,13 @@ export default class Session { return true; } - async runSaga(saga, ...args) { + /** + * @private + * Allows running any saga -- for internal use only! + * Using this could seriously screw up the debugger state if you + * don't know what you're doing! + */ + async _runSaga(saga, ...args) { return await this._sagaMiddleware.run(saga, ...args).toPromise(); } @@ -235,10 +241,20 @@ export default class Session { const definitions = this.view(data.current.identifiers.definitions); const refs = this.view(data.current.identifiers.refs); - return await this.runSaga(decode, definitions[name], refs[name]); + return await this._runSaga(decode, definitions[name], refs[name]); } async variables() { - return await this.runSaga(decodeAll); + let definitions = this.view(data.current.identifiers.definitions); + let refs = this.view(data.current.identifiers.refs); + let decoded = {}; + for (let [identifier, ref] of Object.entries(refs)) { + decoded[identifier] = await this._runSaga( + decode, + definitions[identifier], + ref + ); + } + return decoded; } }