diff --git a/src/Components/Avatar.story.lua b/src/Components/Avatar.story.lua index b382dad..29bfee2 100644 --- a/src/Components/Avatar.story.lua +++ b/src/Components/Avatar.story.lua @@ -38,7 +38,13 @@ return { end end) - local Instance = Scope:Frame { + Scope:innerScope({ + function() + task.cancel(RandomizerThread) + end, + }) + + Scope:Frame { Parent = Parent, Padding = Scope:Computed(function(use) return UDim.new(0, use(Theme.StrokeThickness["4"])) @@ -97,8 +103,7 @@ return { } return function() - Instance:Destroy() - task.cancel(RandomizerThread) + Scope:doCleanup() end end, } diff --git a/src/Components/Badge.story.lua b/src/Components/Badge.story.lua index 7cc7cc9..9e0c94f 100644 --- a/src/Components/Badge.story.lua +++ b/src/Components/Badge.story.lua @@ -24,7 +24,7 @@ return { local NotificationCount = Scope:Value(0) - local CountLoop = task.spawn(function() + local CountThread = task.spawn(function() while task.wait(0.08) do if peek(NotificationCount) == 100 then task.wait(3) @@ -35,7 +35,13 @@ return { end end) - local Instance = Scope:Frame { + Scope:innerScope({ + function() + task.cancel(CountThread) + end, + }) + + Scope:Frame { Parent = Parent, ListEnabled = true, ListPadding = Scope:Computed(function(use) @@ -90,8 +96,7 @@ return { } return function() - Instance:Destroy() - coroutine.close(CountLoop) + Scope:doCleanup() end end, } diff --git a/src/Components/Base.story.lua b/src/Components/Base.story.lua index 06c18c8..c62c07c 100644 --- a/src/Components/Base.story.lua +++ b/src/Components/Base.story.lua @@ -11,7 +11,7 @@ return { local Theme: Themer.ThemeObject = Themer.Theme:now() local Scope: Fusion.Scope = Scoped(Fusion, Components) - local Instance = Scope:Base { + Scope:Base { Parent = Parent, ListEnabled = true, Padding = Scope:Computed(function(use) @@ -108,7 +108,7 @@ return { } return function() - Instance:Destroy() + Scope:doCleanup() end end, } diff --git a/src/Components/Button.story.lua b/src/Components/Button.story.lua index f2b0453..5ad23ff 100644 --- a/src/Components/Button.story.lua +++ b/src/Components/Button.story.lua @@ -19,7 +19,7 @@ return { local Scope: Fusion.Scope = Scoped(Fusion, Components) local Theme: Themer.ThemeObject = Themer.Theme:now() - local Instance = Scope:Frame { + Scope:Frame { Parent = Parent, ListEnabled = true, ListPadding = Scope:Computed(function(use) @@ -71,7 +71,7 @@ return { } return function() - Instance:Destroy() + Scope:doCleanup() end end, } diff --git a/src/Components/Card.story.lua b/src/Components/Card.story.lua index 2d6e068..df23e5e 100644 --- a/src/Components/Card.story.lua +++ b/src/Components/Card.story.lua @@ -22,7 +22,7 @@ return { local Scope: Fusion.Scope = Scoped(Fusion, Components) local Theme: Themer.ThemeObject = Themer.Theme:now() - local Instance = Scope:Frame { + Scope:Frame { Parent = Parent, Size = UDim2.fromOffset(300, 0), AutomaticSize = Enum.AutomaticSize.Y, @@ -63,7 +63,7 @@ return { } return function() - Instance:Destroy() + Scope:doCleanup() end end, } diff --git a/src/Components/Checkbox.lua b/src/Components/Checkbox.lua index 1156bee..ffa2966 100644 --- a/src/Components/Checkbox.lua +++ b/src/Components/Checkbox.lua @@ -65,7 +65,7 @@ return function(Scope: Fusion.Scope, Props: Props) end end) - return BaseButton(Util.CombineProps(Props, { + return Scope:BaseButton(Util.CombineProps(Props, { Name = "Checkbox", BackgroundColor3 = EffectiveColor, BackgroundTransparency = Scope:Spring( diff --git a/src/Components/Checkbox.story.lua b/src/Components/Checkbox.story.lua index d239ee6..63758cf 100644 --- a/src/Components/Checkbox.story.lua +++ b/src/Components/Checkbox.story.lua @@ -19,7 +19,7 @@ return { local Scope: Fusion.Scope = Scoped(Fusion, Components) local Theme: Themer.ThemeObject = Themer.Theme:now() - local Instance = Scope:Frame { + Scope:Frame { Parent = Parent, Padding = Scope:Computed(function(use) return UDim.new(0, use(Theme.StrokeThickness["1"])) @@ -51,7 +51,7 @@ return { } return function() - Instance:Destroy() + Scope:doCleanup() end end, } diff --git a/src/Components/Divider.story.lua b/src/Components/Divider.story.lua index c13953c..619ee9c 100644 --- a/src/Components/Divider.story.lua +++ b/src/Components/Divider.story.lua @@ -20,7 +20,7 @@ return { local Scope: Fusion.Scope = Scoped(Fusion, Components) local Theme: Themer.ThemeObject = Themer.Theme:now() - local Instance = Scope:Frame { + Scope:Frame { Parent = Parent, Size = UDim2.fromOffset(300, 0), AutomaticSize = Enum.AutomaticSize.Y, @@ -44,7 +44,7 @@ return { } return function() - Instance:Destroy() + Scope:doCleanup() end end, } diff --git a/src/Components/Heading.story.lua b/src/Components/Heading.story.lua index 5f3879e..6e2d73d 100644 --- a/src/Components/Heading.story.lua +++ b/src/Components/Heading.story.lua @@ -20,7 +20,7 @@ return { local Scope: Fusion.Scope = Scoped(Fusion, Components) local Theme: Themer.ThemeObject = Themer.Theme:now() - local Instance = Scope:Frame { + Scope:Frame { Parent = Parent, ListEnabled = true, ListPadding = Scope:Computed(function(use) @@ -39,7 +39,7 @@ return { } return function() - Instance:Destroy() + Scope:doCleanup() end end, } diff --git a/src/Components/Icon.story.lua b/src/Components/Icon.story.lua index 4edf89d..f999227 100644 --- a/src/Components/Icon.story.lua +++ b/src/Components/Icon.story.lua @@ -12,13 +12,13 @@ return { story = function(Parent: GuiObject) local Scope: Fusion.Scope = Scoped(Fusion, Components) - local Instance = Scope:Icon { + Scope:Icon { Parent = Parent, Image = "rbxassetid://11560341132", } return function() - Instance:Destroy() + Scope:doCleanup() end end, } diff --git a/src/Components/IconButton.story.lua b/src/Components/IconButton.story.lua index f5f7193..3b5ff96 100644 --- a/src/Components/IconButton.story.lua +++ b/src/Components/IconButton.story.lua @@ -19,7 +19,7 @@ return { local Scope: Fusion.Scope = Scoped(Fusion, Components) local Theme: Themer.ThemeObject = Themer.Theme:now() - local Instance = Scope:Frame { + Scope:Frame { Parent = Parent, Padding = Scope:Computed(function(use) return UDim.new(0, use(Theme.StrokeThickness["1"])) @@ -65,7 +65,7 @@ return { } return function() - Instance:Destroy() + Scope:doCleanup() end end, } diff --git a/src/Components/IconText.story.lua b/src/Components/IconText.story.lua index 1e11a82..4250bfa 100644 --- a/src/Components/IconText.story.lua +++ b/src/Components/IconText.story.lua @@ -12,7 +12,7 @@ return { story = function(Parent: GuiObject) local Scope: Fusion.Scope = Scoped(Fusion, Components) - local Instance = Scope:IconText { + Scope:IconText { Parent = Parent, Content = { "Here's a shop icon: ", @@ -25,7 +25,7 @@ return { } return function() - Instance:Destroy() + Scope:doCleanup() end end, } diff --git a/src/Components/Image.story.lua b/src/Components/Image.story.lua index 24d5c5d..43c6dcf 100644 --- a/src/Components/Image.story.lua +++ b/src/Components/Image.story.lua @@ -18,7 +18,7 @@ return { local Scope: Fusion.Scope = Scoped(Fusion, Components) local Theme: Themer.ThemeObject = Themer.Theme:now() - local Instance = Scope:Frame { + Scope:Frame { Parent = Parent, AutomaticSize = Enum.AutomaticSize.XY, ListEnabled = true, @@ -39,7 +39,7 @@ return { } return function() - Instance:Destroy() + Scope:doCleanup() end end, } diff --git a/src/Components/MenuFrame.story.lua b/src/Components/MenuFrame.story.lua index 753630e..84ccc38 100644 --- a/src/Components/MenuFrame.story.lua +++ b/src/Components/MenuFrame.story.lua @@ -20,7 +20,7 @@ return { local Scope: Fusion.Scope = Scoped(Fusion, Components) local Theme: Themer.ThemeObject = Themer.Theme:now() - local Instance = Scope:Frame { + Scope:Frame { Parent = Parent, Padding = Scope:Computed(function(use) return UDim.new(0, use(Theme.StrokeThickness["1"])) @@ -44,7 +44,7 @@ return { } return function() - Instance:Destroy() + Scope:doCleanup() end end, } diff --git a/src/Components/NumberSpinner.story.lua b/src/Components/NumberSpinner.story.lua index bd2bdba..1c2de53 100644 --- a/src/Components/NumberSpinner.story.lua +++ b/src/Components/NumberSpinner.story.lua @@ -37,7 +37,15 @@ return { end end) - local Instance = Scope:Frame { + Scope:innerScope({ + function() + task.cancel(RandomizerThread) + task.cancel(RandomizerDecimalThread) + task.cancel(CountThread) + end, + }) + + Scope:Frame { Parent = Parent, Size = UDim2.fromOffset(300, 0), AutomaticSize = Enum.AutomaticSize.Y, @@ -62,10 +70,7 @@ return { } return function() - task.cancel(RandomizerThread) - task.cancel(RandomizerDecimalThread) - task.cancel(CountThread) - Instance:Destroy() + Scope:doCleanup() end end, } diff --git a/src/Components/ProgressBar.story.lua b/src/Components/ProgressBar.story.lua index 44bb9ee..a8ab062 100644 --- a/src/Components/ProgressBar.story.lua +++ b/src/Components/ProgressBar.story.lua @@ -26,7 +26,20 @@ return { local Progress = Scope:Value(0) local Color = Scope:Value(Color3.fromRGB(255, 0, 0)) - local Instance = Scope:Frame { + local ColorThread = task.spawn(function() + while task.wait(1) do + Progress:set(math.random(0, 1000) / 1000) + Color:set(ColorUtils.Rotate(peek(Color), 100)) + end + end) + + Scope:innerScope({ + function() + task.cancel(ColorThread) + end, + }) + + Scope:Frame { Parent = Parent, ListEnabled = true, ListHorizontalFlex = Enum.UIFlexAlignment.Fill, @@ -186,15 +199,8 @@ return { }, } - task.spawn(function() - while task.wait(1) do - Progress:set(math.random(0, 1000) / 1000) - Color:set(ColorUtils.Rotate(peek(Color), 100)) - end - end) - return function() - Instance:Destroy() + Scope:doCleanup() end end, } diff --git a/src/Components/ScrollingFrame.story.lua b/src/Components/ScrollingFrame.story.lua index 16e16c9..6557760 100644 --- a/src/Components/ScrollingFrame.story.lua +++ b/src/Components/ScrollingFrame.story.lua @@ -12,7 +12,7 @@ return { story = function(Parent: GuiObject) local Scope: Fusion.Scope = Scoped(Fusion, Components) - local Instance = Scope:ScrollingFrame { + Scope:ScrollingFrame { Parent = Parent, Size = UDim2.fromOffset(200, 200), CanvasSize = UDim2.new(UDim.new(1, 0), UDim.new(0, 1000)), @@ -20,7 +20,7 @@ return { } return function() - Instance:Destroy() + Scope:doCleanup() end end, } diff --git a/src/Components/SwitchInput.story.lua b/src/Components/SwitchInput.story.lua index e0f2be4..b15235d 100644 --- a/src/Components/SwitchInput.story.lua +++ b/src/Components/SwitchInput.story.lua @@ -18,7 +18,7 @@ return { local Scope: Fusion.Scope = Scoped(Fusion, Components) local Theme: Themer.ThemeObject = Themer.Theme:now() - local Instance = Scope:Frame { + Scope:Frame { Parent = Parent, Padding = Scope:Computed(function(use) return UDim.new(0, use(Theme.StrokeThickness["1"])) @@ -37,7 +37,7 @@ return { } return function() - Instance:Destroy() + Scope:doCleanup() end end, } diff --git a/src/Components/Text.story.lua b/src/Components/Text.story.lua index be03da1..3a655ae 100644 --- a/src/Components/Text.story.lua +++ b/src/Components/Text.story.lua @@ -12,13 +12,12 @@ return { story = function(Parent: GuiObject) local Scope: Fusion.Scope = Scoped(Fusion, Util, Components) - local Instance = Scope:Text { + Scope:Text { Parent = Parent, Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", } return function() - Instance:Destroy() Scope:doCleanup() end end, diff --git a/src/Components/TextArea.story.lua b/src/Components/TextArea.story.lua index c2f9490..08803f4 100644 --- a/src/Components/TextArea.story.lua +++ b/src/Components/TextArea.story.lua @@ -18,7 +18,7 @@ return { local Scope: Fusion.Scope = Scoped(Fusion, Components) local Theme: Themer.ThemeObject = Themer.Theme:now() - local Instance = Scope:Frame { + Scope:Frame { Parent = Parent, Size = UDim2.fromOffset(250, 0), AutomaticSize = Enum.AutomaticSize.Y, @@ -53,7 +53,7 @@ return { } return function() - Instance:Destroy() + Scope:doCleanup() end end, } diff --git a/src/Components/TextInput.story.lua b/src/Components/TextInput.story.lua index d5b697e..2bef683 100644 --- a/src/Components/TextInput.story.lua +++ b/src/Components/TextInput.story.lua @@ -18,7 +18,7 @@ return { local Scope: Fusion.Scope = Scoped(Fusion, Components) local Theme: Themer.ThemeObject = Themer.Theme:now() - local Instance = Scope:Frame { + Scope:Frame { Parent = Parent, Size = UDim2.fromOffset(250, 0), AutomaticSize = Enum.AutomaticSize.Y, @@ -49,7 +49,7 @@ return { } return function() - Instance:Destroy() + Scope:doCleanup() end end, } diff --git a/src/Components/TitleBar.story.lua b/src/Components/TitleBar.story.lua index baffb1e..5732c0a 100644 --- a/src/Components/TitleBar.story.lua +++ b/src/Components/TitleBar.story.lua @@ -18,7 +18,7 @@ return { local Scope: Fusion.Scope = Scoped(Fusion, Components) local Theme: Themer.ThemeObject = Themer.Theme:now() - local Instance = Scope:Frame { + Scope:Frame { Parent = Parent, Padding = Scope:Computed(function(use) return UDim.new(0, use(Theme.StrokeThickness["1"])) @@ -41,7 +41,7 @@ return { } return function() - Instance:Destroy() + Scope:doCleanup() end end, } diff --git a/src/Examples/SettingsMenu.story.lua b/src/Examples/SettingsMenu.story.lua index d381b1a..f294aa4 100644 --- a/src/Examples/SettingsMenu.story.lua +++ b/src/Examples/SettingsMenu.story.lua @@ -18,7 +18,7 @@ return { local Scope: Fusion.Scope = Scoped(Fusion, Components) local Theme: Themer.ThemeObject = Themer.Theme:now() - local Instance = Scope:Frame { + Scope:Frame { Parent = Parent, Padding = Scope:Computed(function(use) return UDim.new(0, use(Theme.StrokeThickness["1"])) @@ -30,7 +30,7 @@ return { } return function() - Instance:Destroy() + Scope:doCleanup() end end, } diff --git a/src/Test.story.lua b/src/Test.story.lua index 0896c69..14298b2 100644 --- a/src/Test.story.lua +++ b/src/Test.story.lua @@ -69,7 +69,6 @@ return function(Parent: GuiObject) } return function() - Object:Destroy() Scope:doCleanup() end end