Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/utils/show.luau
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ local read = require("./read")
local types = require("../reactive/types")
local untrack = require("../reactive/untrack")

local function show<T, U>(condition: () -> any, truthy: types.UsedAs<T>, falsy: types.UsedAs<U>?): () -> T | U
local function show<T, U>(
condition: types.UsedAs<any>,
truthy: types.UsedAs<T>,
falsy: types.UsedAs<U>?
): () -> T | U
return derive(function()
if condition() then
if read(condition) then
return untrack(function()
return read(truthy)
end)
Expand All @@ -19,8 +23,11 @@ local function show<T, U>(condition: () -> any, truthy: types.UsedAs<T>, falsy:
end)
end

return show :: & (<T>(condition: () -> any, truthy: types.UsedAs<T>) -> () -> read.CastIntoValue<T>?) & <T, U>(
condition: () -> any,
return show :: & (<T>(
condition: types.UsedAs<any>,
truthy: types.UsedAs<T>
) -> () -> read.CastIntoValue<T>?) & <T, U>(
condition: types.UsedAs<any>,
truthy: types.UsedAs<T>,
falsy: types.UsedAs<U>
) -> () -> T | U