Skip to content

Commit

Permalink
keys system revamp
Browse files Browse the repository at this point in the history
  • Loading branch information
jmesrje committed Nov 9, 2024
1 parent 1ab3819 commit 9af227f
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 230 deletions.
2 changes: 1 addition & 1 deletion src/Instances/New.luau
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ return function<T>(

Component = Result
else -- If it wasn't successful, error it because instance creation has to be complete.
Debugger.Fatal("FailedToCreate", component, Result)
Debugger.Fatal("FailedCreation", component, Result)
end
else
if children then
Expand Down
25 changes: 25 additions & 0 deletions src/Keys/Change.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
-- Variables
local Packages = script.Parent.Parent.Parent.Parent.Packages
local Utility = script.Parent.Utility
local Keys = require(Utility.Keys)
local Debugger = require(Packages.debugger)

-- Module

--[=[
Connects a callback to a certain property change event.
[Learn More](https://luminlabsdev.github.io/ui-framework/api/keys/#change)
]=]
return function(prop: string)
if not Keys["Change"] then
Keys["Change"] = function(instance: Instance, callback: (...any) -> ())
local Success, Event = pcall(instance.GetPropertyChangedSignal, instance :: any, prop :: any)
if not Success or type(callback) ~= "function" then
Debugger.Fatal("")
end
Event:Connect(callback)
end
end
return Keys["Change"]
end
26 changes: 26 additions & 0 deletions src/Keys/Event.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
-- Variables
local Packages = script.Parent.Parent.Parent.Parent.Packages
local Utility = script.Parent.Utility
local FindProp = require(Utility.FindProp)
local Keys = require(Utility.Keys)
local Debugger = require(Packages.debugger)

-- Module

--[=[
Connects a callback to an event on the instance.
[Learn More](https://luminlabsdev.github.io/ui-framework/api/keys/#event)
]=]
return function(event: string)
if not Keys["Event"] then
Keys["Event"] = function(instance: Instance, callback: (...any) -> ())
local Success, Event = pcall(FindProp, instance :: any, event :: any)
if not Success or type(callback) ~= "function" then
Debugger.Fatal("")
end
Event:Connect(callback)
end
end
return Keys["Event"]
end
47 changes: 0 additions & 47 deletions src/Keys/Key.luau

This file was deleted.

Empty file.
28 changes: 0 additions & 28 deletions src/Keys/List/OnChange.luau

This file was deleted.

29 changes: 0 additions & 29 deletions src/Keys/List/OnEvent.luau

This file was deleted.

46 changes: 0 additions & 46 deletions src/Keys/RegisterKey.luau

This file was deleted.

19 changes: 19 additions & 0 deletions src/Keys/Tag.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-- Variables
local Utility = script.Parent.Utility
local Keys = require(Utility.Keys)

-- Module

--[=[
Adds a tag with the provided name to the instance.
[Learn More](https://luminlabsdev.github.io/ui-framework/api/keys/#tag)
]=]
return function()
if not Keys["Tag"] then
Keys["Tag"] = function(instance: Instance, name: string)
instance:AddTag(name)
end
end
return Keys["Tag"]
end
41 changes: 0 additions & 41 deletions src/Keys/UnregisterKey.luau

This file was deleted.

8 changes: 7 additions & 1 deletion src/Logs.luau
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
return {

IncompatibleType = "Data type '%s' is incompatible",
NotAnimatable = "%s is not an animatable object",
FailedCreation = "%s could not be created; '%s'",

InvalidType = "Expected type %s; got '%s'",
InvalidKey = "Expected valid key type; got '%s'",
InvalidClass = "'%s' is not an instance class name",
}
37 changes: 0 additions & 37 deletions src/Utility/Debugger.luau

This file was deleted.

0 comments on commit 9af227f

Please sign in to comment.