UNPKG

@jbrowse/plugin-wiggle

Version:

JBrowse 2 wiggle adapters, tracks, etc.

36 lines (35 loc) 1.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getQuantitativeStatsAutorun = getQuantitativeStatsAutorun; const util_1 = require("@jbrowse/core/util"); const stopToken_1 = require("@jbrowse/core/util/stopToken"); const mobx_1 = require("mobx"); const mobx_state_tree_1 = require("mobx-state-tree"); const getQuantitativeStats_1 = require("./getQuantitativeStats"); function getQuantitativeStatsAutorun(self) { (0, mobx_state_tree_1.addDisposer)(self, (0, mobx_1.autorun)(async () => { try { if (self.quantitativeStatsReady) { const view = (0, util_1.getContainingView)(self); const stopToken = (0, stopToken_1.createStopToken)(); self.setStatsLoading(stopToken); const statsRegion = JSON.stringify(view.dynamicBlocks); const wiggleStats = await (0, getQuantitativeStats_1.getQuantitativeStats)(self, { stopToken, filters: [], currStatsBpPerPx: view.bpPerPx, ...self.adapterProps(), }); if ((0, mobx_state_tree_1.isAlive)(self)) { self.updateQuantitativeStats(wiggleStats, statsRegion); } } } catch (e) { if ((0, mobx_state_tree_1.isAlive)(self) && !(0, util_1.isAbortException)(e)) { console.error(e); self.setError(e); } } }, { delay: 1000 })); }