GraphObject ¶
export type GraphObject = ScopedObject & {
createdAt: number
dependencySet: {[GraphObject]: unknown},
dependentSet: {[GraphObject]: unknown},
lastChange: number?,
timeliness: "lazy" | "eager",
validity: "valid" | "invalid" | "busy",
_evaluate: (GraphObject, lastChange: number?) -> boolean
}
A reactive graph object which can broadcast and receive updates among other members of the reactive graph.
This type includes ScopedObject
, which
allows the lifetime and destruction order of the reactive graph to be analysed.
Non-standard type syntax
The above type definition uses self
to denote methods. At time of writing,
Luau does not interpret self
specially.
Members¶
createdAt : number ¶
The os.clock()
time of this object's construction, measured as early as
possible in the object's constructor.
dependencySet : {[GraphObject]: unknown} ¶
Everything this reactive graph object currently declares itself as dependent upon.
dependentSet : {[GraphObject]: unknown} ¶
The reactive graph objects which declare themselves as dependent upon this object.
lastChange : number? ¶
The os.clock()
time of this object's most recent meaningful change, or nil
if the object is newly created.
timeliness : "lazy" | "eager" ¶
Describes when this object expects to be revalidated. Most objects should use
lazy
timeliness to defer computation as late as possible. However, if it's
important for this object to respond to changes as soon as possible, for example
for the purposes of observation, then eager
timeliness ensures that a
revalidation is dispatched as soon as possible.
validity : "valid" | "invalid" | "busy" ¶
Whether the most recent validation operation done on this graph object was a
revalidation or an invalidation. busy
is used while the graph object is in
the middle of a revalidation.
Methods¶
_evaluate -> boolean ¶
function GraphObject:_evaluate(): boolean
Called by Fusion while the graph object is in the process of being evaluated. This is where logic to do with computational updates should be placed.
The return value is true
when a 'meaningful change' occurs because of this
revalidation. A 'meaningful change' is one that would affect dependencies'
behaviour. This is used to efficiently skip over calculations for dependencies.
Restrictions
This method should finish without spawning new processes, blocking the thread, or erroring.