TableEvents v1 - API Reference

Welcome to my very first Open-Source Module! TableEvents v1

How To Use

local TableEvents = require(game.ReplicatedStorage.TableEvents) or require(6300553152)() -- Parents to ReplicatedStorage by default.
local ourTable = TableEvents.new(<table> table) --  The table argument is not required only necessary if you want to set table values ahead of time.

Functions

> table:GetEvents() -- Returns Table Of Events (BindableEvent.Event) <table>
> -
> Added <event> Args(index <variant>, newValue <variant>) -- Fires When A Value Is Added
> Changed <event> Args(index <variant>, oldValue <variant>, newValue <variant>) -- Fires When A Value Is Changed
> Removed <event> Args(index <variant>, oldValue <variant>) -- Fires When A Value Is Removed From The Table (nil)
> Retrieved <event> Args(index <variant>,  currentValue <variant>) -- Fires When A Value Is Retrieved From The Table
> table:GetRawTable() -- Returns A Copy Of The Original Table (Used For Iteration) <table>
> -
> for i,v in pairs(table:GetRawTable()) do
> print(i,v)
> end
> table:Rawset(index <variant>, newValue <variant>) -- Sets A Table's Value Without Firing Any Events & Ignores ReadOnly
> -
> table:Rawset(1,true)
> table:Rawget(index <variant>) -- Gets A Table's Value Without Firing Any Events <variant>
> -
> print(table:Rawget(1))
> table:SetReadOnly(boolean <boolean>) -- Sets Whether The Table Is Editable
> -
> table:SetReadOnly(true)
> table:GetReadOnly() -- Gets Whether The Table Is Editable <boolean>
> -
> print(table:GetReadOnly()) -- true or false

Enjoy! Contact me at:
𝔰𝔩𝔒𝔒𝔭𝔠𝔬𝔑𝔒𝔰#0001

More features in the future?? Reply to this message to let me know!!

1 Like

An example of how to automatically print events:

for eventName,v in pairs(table:GetEvents()) do
	v:Connect(function(...)
	print(eventName,...)
	end)
end

Here’s another:

local module = require(6300553152)()
local tab = module.new({a=true})
for i,v in pairs(tab:GetEvents()) do
	v:Connect(function(...)
	print(i,...)
	end)
end
tab:SetReadOnly(true)
tab.a = "Oooh"
print(tab.a)
tab:SetReadOnly(false)
tab.a = "Ahh"
print(tab.a)