diff --git a/src/utils/show.luau b/src/utils/show.luau index d50a366..6395441 100644 --- a/src/utils/show.luau +++ b/src/utils/show.luau @@ -3,9 +3,13 @@ local read = require("./read") local types = require("../reactive/types") local untrack = require("../reactive/untrack") -local function show(condition: () -> any, truthy: types.UsedAs, falsy: types.UsedAs?): () -> T | U +local function show( + condition: types.UsedAs, + truthy: types.UsedAs, + falsy: types.UsedAs? +): () -> T | U return derive(function() - if condition() then + if read(condition) then return untrack(function() return read(truthy) end) @@ -19,8 +23,11 @@ local function show(condition: () -> any, truthy: types.UsedAs, falsy: end) end -return show :: & ((condition: () -> any, truthy: types.UsedAs) -> () -> read.CastIntoValue?) & ( - condition: () -> any, +return show :: & (( + condition: types.UsedAs, + truthy: types.UsedAs + ) -> () -> read.CastIntoValue?) & ( + condition: types.UsedAs, truthy: types.UsedAs, falsy: types.UsedAs ) -> () -> T | U