From 9ddc5d74c480ca4606941a509148e2ca7c0d0c32 Mon Sep 17 00:00:00 2001 From: Joshua Taylor <43937497+TaylorsRus@users.noreply.github.com> Date: Wed, 21 Oct 2026 22:57:42 +0100 Subject: [PATCH] Update `show` utility to permit `UsedAs` condition this doesn't introduce any downsides, the upside is that we can use the utility for logic trees that perhaps aren't reactive, but still want to create variants based on args shown, such as an item which may shown an icon in one part of the app, but no icon in another Signed-off-by: Joshua Taylor <43937497+TaylorsRus@users.noreply.github.com> --- src/utils/show.luau | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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