Global Framework

Global Library Updated 1.3

image

Added SignalManager & Table
bug fix Thread


Fixed typo in Thread and functions now return the correct type

Table provides two commonly used functions Clone & Reconcile

SignalManager is used to help manage signal connections

function Character.new(instance)
	local self = Global.Metatable(Character) :: Global.Character
	-- Create a SignalManager and connect two signals
	self.Signals = Global.SignalManager()
	self.Signals:Connect(instance.AttributeChanged, Character.AttributeChanged, self)
	self.Signals:Connect(instance.AnimationController.Animator.AnimationPlayed, Character.AnimationPlayed, self)
	return self
end

function Character:AttributeChanged(attribute)
	print(attribute)
end

function Character:AnimationPlayed(animationTrack)
	print(animationTrack)
end

function Character:Destroy()
	-- Disconnect all signals from the SignalManager
	self.Signals:DisconnectAll()
end
2 Likes

Global Library Updated 1.4

image

Removed <P> generic from ParameterEvent, ParameterTimer and SignalManager because there where some small edge cases where the type checking engine would fail

Added Table2D and Table3D

-- Make a 2d table that has string values and number keys
local table2D = Global.Table2D()-- :: Global.Table2D<string, number>

-- Add ABC to index 5x2
table2D:Set(5, 2, "ABC")

print(table2D:Get(5, 2))

-- Remove ABC from index 5x2
table2D:Set(5, 2, nil)
1 Like


typeError signalManager needs capital M

Thank you for reporting this I have fixed it :slight_smile:

1 Like

I noticed that this also happens even with a regular script, when you put a return at itā€™s last line. Not something that I would do normally, Just something that I found randomly, wanted to let you know :slight_smile:

I just tested this for myself and everything worked perfectly fine with a return at the bottom of a script so Iā€™m guessing the problem you experienced was with something else

1 Like

Oh strange, I tried reproducing it as well again and it seems to be working fine. Must have been something else like you said. Unfortunately I no longer have the project file with the bug I mentioned earlier. Iā€™ll let you know if I find it again :sweat_smile:

Hi! In your next update can you add support for writing custom code before Global framework adds its own types?

^
I want to use FastSignal module with this framework. However, to use this moduleā€™s types properly, I must require it before the globalā€™s types are set.

The reason Iā€™m requiring modules and setting itā€™s types manually, as shown above, is because it is currently difficult to add types using the bracket comments method with modules that donā€™t have the global framework in mind. For example, Iā€™m using Trove which is a cleanup module by Sleitnick. In order to add the Trove type through the bracket comments method provided by the plugin, I would need to heavily modify the original code, as Trove has a multitude of types it uses within it.

To get around this and simplify the process, inside the global framework module under the ā€˜local globals = {}ā€™ line, I require the trove module and simply get its type though there. And then afterwards I can use the Trove type though the Global framework normally. Currently this is the only place where edits to the module are not overwritten by the plugin.

image

This works fine with trove, However with FastSignal its a different story since it uses generics.

image

^ If I attempt to do this with the method I talked about, then every time I try to use the FastSignal type through Global, I canā€™t input my own arguments inside the <> brackets.

To be able to use the generics and global framework properly, I need to require FastSignal before the Globalā€™s types are set. That way in my other scripts I can do the following:

image

here is one option of how you can bring a external module into global

--[[type TroveConstructor = typeof(require(game.ServerStorage.Trove))]]
--[[type Trove = typeof(require(game.ServerStorage.Trove).new())]]

local Global = require(script.Parent)

Global("Trove", require(game.ServerStorage.Trove) :: Global.TroveConstructor)

and here is a example of a class using the trove type

in other modules you might not even need the TroveConstructor type but because trove is setup a bit differently where it returns a separate table

image

this is why we had to make the separate TroveConstructor

1 Like

Thatā€™s intresting :thinking:
How would I do this with FastSignal that needs generics arguments?

I tried doing this but it isnā€™t working:

But I really think that allowing to let people write code above the global types is the best way to do this.