State

สร้างตัวแปรพร้อมกับการ Handle Value Change ซึ่งจะทำให้คุณสามารถตรวจสอบควบคุมการเปลี่ยนแปลงตัวแปรได้ในทันทีเมื่อมีการเปลี่ยน โดยการใช้งานมีดังนี้
-- NS.createState(value, fn)

local hasOpen, setHasOpen = NS.createState(true, function(previous, current)
	print('log: previous', previous)
	print('log: current', current)
end)

print('hasOpen', hasOpen)
setHasOpen(false)

-- output:
-- hasOpen true
-- log: previous true
-- log: current false
ParameterTypeDescriptionNote
valueanyค่าเริ่มต้น
fnfun(previous: any, current: any)ฟังก์ชั่นเมื่อมีการเปลี่ยนแปลงข้อมูล