diff --git a/lib/future.luau b/lib/future.luau index 5e7c21b..766c4f4 100644 --- a/lib/future.luau +++ b/lib/future.luau @@ -4,16 +4,11 @@ local mod = require("../mod") local Signal = mod.signal type Signal = mod.Signal -local option = require("option") -type Option = option.Option -local Some = option.Some -local None = option.None - local Future = {} export type Status = "initialized" | "running" | "cancelled" | "done" export type Future = typeof(Future) & { _fn: (set: (value: T) -> ()) -> T, - _ret: T?, + _ret: T, _thread: thread, _spawnEvt: Signal<()>, _retEvt: Signal, @@ -40,7 +35,7 @@ function Future.new(fn: (...any) -> T, args: { any }) ) end -function Future.poll(self: Future): (Status, Option) +function Future.poll(self: Future): (Status, T) if self._status == "initialized" then self._retEvt:Connect(function(firedRet, status: Status) self._status = status @@ -66,8 +61,7 @@ function Future.poll(self: Future): (Status, Option) task.wait(0.01) end - local retOpt = if self._ret == nil then None() else Some(self._ret) - return self._status, retOpt + return self._status, self._ret end function Future.cancel(self: Future)