diff --git a/lib/Internal.lua b/lib/Internal.lua index 22c2ed4..0076d24 100644 --- a/lib/Internal.lua +++ b/lib/Internal.lua @@ -161,6 +161,7 @@ return function(Iris: Types.Iris): Types.Internal @within State @method onChange @param callback (newValue: T) -> () + @return () -> () Allows the caller to connect a callback which is called when the states value is changed. @@ -177,6 +178,17 @@ return function(Iris: Types.Iris): Types.Internal end end + --[=[ + @within State + @method changed + @return boolean + + Returns true if the state was changed on this frame. + ]=] + function StateClass:changed(): boolean + return self.lastChangeTick + 1 == Internal._cycleTick + end + Internal.StateClass = StateClass --[[ diff --git a/lib/WidgetTypes.lua b/lib/WidgetTypes.lua index 5a5a1e7..814b0e0 100644 --- a/lib/WidgetTypes.lua +++ b/lib/WidgetTypes.lua @@ -18,6 +18,7 @@ export type State = { get: (self: State) -> T, set: (self: State, newValue: T, force: true?) -> (), onChange: (self: State, funcToConnect: (newValue: T) -> ()) -> () -> (), + changed: (self: State) -> boolean, } --[=[