UNPKG

vscroll

Version:
61 lines 1.52 kB
import { Reactive } from '../reactive'; class InnerLoopModel { get first() { return this.count === 0; } constructor(total) { this.total = total; this.isInitial = false; this.busy = new Reactive(false); } done() { this.isInitial = false; this.count++; this.total++; this.busy.set(false); } start() { this.busy.set(true); } dispose() { this.busy.dispose(); } } export class WorkflowCycleModel { get loopId() { return `${this.instanceIndex}-${this.count}-${this.innerLoop.total}`; } get loopIdNext() { return `${this.instanceIndex}-${this.count}-${this.innerLoop.total + 1}`; } constructor(instanceIndex, cycle) { const cycleCount = cycle ? cycle.count : 1; const loopCount = cycle ? cycle.innerLoop.count : 0; this.instanceIndex = instanceIndex; this.innerLoop = new InnerLoopModel(loopCount); this.interrupter = null; this.busy = new Reactive(false); this.end(cycleCount); } start(isInitial, initiator) { this.isInitial = isInitial; this.initiator = initiator; this.innerLoop.isInitial = isInitial; this.innerLoop.count = 0; this.interrupter = null; this.busy.set(true); } end(count) { this.count = count; this.isInitial = false; this.busy.set(false); } dispose(forever) { if (forever) { // otherwise the value will be persisted during re-instantiation this.busy.dispose(); } this.innerLoop.dispose(); } } //# sourceMappingURL=cycle.js.map