Observer ¶
export type Observer = GraphObject & {
type: "Observer",
timeliness: "eager",
onChange: (self, callback: () -> ()) -> (() -> ()),
onBind: (self, callback: () -> ()) -> (() -> ())
}
A graph object that runs user code when it's updated by the reactive graph.
Non-standard type syntax
The above type definition uses self
to denote methods. At time of writing,
Luau does not interpret self
specially.
Members¶
type : "Observer" ¶
A type string which can be used for runtime type checking.
Methods¶
onChange -> (() -> ()) ¶
function Observer:onChange(
callback: () -> ()
): (() -> ())
Registers the callback to run when an update is received.
The returned function will unregister the callback.
onBind -> (() -> ()) ¶
function Observer:onBind(
callback: () -> ()
): (() -> ())
Runs the callback immediately, and registers the callback to run when an update is received.
The returned function will unregister the callback.