--[[
	Constructs and returns objects which can be used to model independent
	reactive state.
]]


local Dependencies = require(script.Parent.Parent.Dependencies)
local utility = Dependencies.utility

local class = {}

local CLASS_METATABLE = {__index = class}
local WEAK_KEYS_METATABLE = {__mode = "k"}

local function Value(initalValue: unknown)
	local self = setmetatable({
		type = "State",
		kind = "Value",
		-- if we held strong references to the dependents, then they wouldn't be
		-- able to get garbage collected when they fall out of scope
		-- contains all `get` requests
		dependentSet = setmetatable({}, WEAK_KEYS_METATABLE),
		_value = initalValue
	}, CLASS_METATABLE)
	
	return self
end
