Skip to content

Commit 64fda59

Browse files
committed
better promise code
1 parent 260e40c commit 64fda59

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

client/src/CostCentreStack.svelte

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
1010
let ghcStgApp = '/home/csaba/haskell/grin-compiler/ghc-wpc-sample-programs/game-logic-experiment/.stack-work/dist/x86_64-linux/Cabal-3.2.0.0/build/minigame/minigame.ghc_stgapp';
1111
//let ghcStgApp = '';
12-
let moduleMap = {};
12+
let moduleMap;
1313
let stackModuleSource = {};
1414
1515
const errorCostCentre = {
@@ -43,7 +43,7 @@
4343
// load stack module sources
4444
let oldModuleSource = stackModuleSource;
4545
stackModuleSource = {}
46-
if (ghcStgApp) {
46+
if (moduleMap) {
4747
currentStackData.forEach(d => stackModuleSource[d.evSpec.heapProfModule] = null);
4848
for (let moduleName in stackModuleSource) {
4949
if (moduleName in oldModuleSource && oldModuleSource[moduleName]) {
@@ -168,12 +168,9 @@
168168
dataCCS.forEach(d => costCentreMap[d.evSpec.heapProfCostCentreId] = d);
169169
//console.log('costCentreMap', costCentreMap);
170170
171-
if (ghcStgApp) {
172-
postData('http://localhost:3000/ext-stg/get-module-mapping', { ghcStgAppPath: ghcStgApp}).then(d => {moduleMap = d; calculateCurrentStack();});
173-
} else {
174-
moduleMap = {};
175-
calculateCurrentStack();
176-
}
171+
postData('http://localhost:3000/ext-stg/get-module-mapping', {ghcStgAppPath: ghcStgApp})
172+
.then(d => {moduleMap = d;}, _ => {moduleMap = null;})
173+
.finally(calculateCurrentStack);
177174
}
178175
179176
const colorScheme = d3.schemeDark2;//d3.schemeTableau10;

0 commit comments

Comments
 (0)