@matechs/effect
Advanced tools
Comparing version 1.4.0 to 1.4.1
import { Either } from "fp-ts/lib/Either"; | ||
import { FunctionN, Lazy } from "fp-ts/lib/function"; | ||
import { FunctionN } from "fp-ts/lib/function"; | ||
import { Cause, Exit } from "./original/exit"; | ||
@@ -61,3 +61,2 @@ import { Runtime } from "./original/runtime"; | ||
interruptRegionStack: boolean[] | undefined; | ||
cancelAsync: Lazy<void> | undefined; | ||
envStack: L.List<any>; | ||
@@ -68,4 +67,2 @@ constructor(runtime?: Runtime); | ||
complete(a: Exit<E, A>): void; | ||
onExit(f: FunctionN<[Exit<E, A>], void>): Lazy<void>; | ||
exit(): Exit<E, A> | null; | ||
isInterruptible(): boolean; | ||
@@ -78,3 +75,2 @@ handle(e: Cause<unknown>): T.Instructions | undefined; | ||
resume(status: Either<unknown, unknown>): void; | ||
contextSwitch(op: FunctionN<[FunctionN<[Either<unknown, unknown>], void>], Lazy<void>>): void; | ||
loop(go: T.Instructions): void; | ||
@@ -81,0 +77,0 @@ start(run: T.Effect<{}, E, A>): Either<Error, Exit<E, A>>; |
@@ -84,24 +84,2 @@ "use strict"; | ||
}; | ||
DriverSyncImpl.prototype.onExit = function (f) { | ||
var _this = this; | ||
if (this.completed !== null) { | ||
f(this.completed); | ||
} | ||
if (this.listeners === undefined) { | ||
this.listeners = [f]; | ||
} | ||
else { | ||
this.listeners.push(f); | ||
} | ||
// TODO: figure how to trigger if possible | ||
/* istanbul ignore next */ | ||
return function () { | ||
if (_this.listeners !== undefined) { | ||
_this.listeners = _this.listeners.filter(function (cb) { return cb !== f; }); | ||
} | ||
}; | ||
}; | ||
DriverSyncImpl.prototype.exit = function () { | ||
return this.completed; | ||
}; | ||
DriverSyncImpl.prototype.isInterruptible = function () { | ||
@@ -141,3 +119,3 @@ return this.interruptRegionStack !== undefined && | ||
DriverSyncImpl.prototype.resumeInterrupt = function () { | ||
this.runtime.dispatch(this.dispatchResumeInterrupt.bind(this), undefined); | ||
this.dispatchResumeInterrupt(); | ||
}; | ||
@@ -181,20 +159,4 @@ DriverSyncImpl.prototype.next = function (value) { | ||
DriverSyncImpl.prototype.resume = function (status) { | ||
this.cancelAsync = undefined; | ||
this.runtime.dispatch(this.foldResume.bind(this), status); | ||
this.foldResume(status); | ||
}; | ||
DriverSyncImpl.prototype.contextSwitch = function (op) { | ||
var _this = this; | ||
var complete = false; | ||
var wrappedCancel = op(function (status) { | ||
if (complete) { | ||
return; | ||
} | ||
complete = true; | ||
_this.resume(status); | ||
}); | ||
this.cancelAsync = function () { | ||
complete = true; | ||
wrappedCancel(); | ||
}; | ||
}; | ||
// tslint:disable-next-line: cyclomatic-complexity | ||
@@ -266,3 +228,2 @@ DriverSyncImpl.prototype.loop = function (go) { | ||
case T.EffectTag.Async: | ||
this.contextSwitch(current.f0); | ||
current = undefined; | ||
@@ -325,6 +286,2 @@ break; | ||
this.interrupted = true; | ||
if (this.cancelAsync && this.isInterruptible()) { | ||
this.cancelAsync(); | ||
this.resumeInterrupt(); | ||
} | ||
}; | ||
@@ -331,0 +288,0 @@ return DriverSyncImpl; |
@@ -405,3 +405,3 @@ import { Bifunctor3 } from "fp-ts/lib/Bifunctor"; | ||
*/ | ||
export declare function forever<R, E, A>(io: Effect<R, E, A>): Effect<R, E, A>; | ||
export declare function forever<R, E, A>(io: Effect<R, E, A>): Effect<R, E, never>; | ||
/** | ||
@@ -408,0 +408,0 @@ * Create an IO that traps all exit states of io. |
{ | ||
"name": "@matechs/effect", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"license": "MIT", | ||
@@ -32,3 +32,3 @@ "private": false, | ||
}, | ||
"gitHead": "f32306b49c070dd6448a9950f8cf300ad41680c9" | ||
"gitHead": "e39b784c6c376ea30cbe5c6b2c5d36ef05eafc32" | ||
} |
Sorry, the diff of this file is not supported yet
422562
7360