UNPKG

@jbrowse/plugin-wiggle

Version:

JBrowse 2 wiggle adapters, tracks, etc.

36 lines (35 loc) 1.34 kB
import { getContainingView, getSession } from '@jbrowse/core/util'; import { isAbortException } from '@jbrowse/core/util/aborting'; import { createStopToken } from '@jbrowse/core/util/stopToken'; import { getRpcSessionId } from '@jbrowse/core/util/tracks'; import { autorun } from 'mobx'; import { addDisposer, isAlive } from 'mobx-state-tree'; export function getMultiWiggleSourcesAutorun(self) { addDisposer(self, autorun(async () => { try { const view = getContainingView(self); if (!view.initialized) { return; } const { rpcManager } = getSession(self); const { adapterConfig } = self; const token = createStopToken(); self.setSourcesLoading(token); const sessionId = getRpcSessionId(self); const sources = (await rpcManager.call(sessionId, 'MultiWiggleGetSources', { regions: view.staticBlocks.contentBlocks, sessionId, adapterConfig, })); if (isAlive(self)) { self.setSources(sources); } } catch (e) { if (!isAbortException(e) && isAlive(self)) { console.error(e); getSession(self).notifyError(`${e}`, e); } } })); }