Skip to content

TinyStaticProperty

Overview

An observable stub which satisfies some of the Property interface, which can store a (static/constant) value and also notify listeners when that value has mutated. The actual value reference does not change, however it can itself be mutated.

@author Sam Reid (PhET Interactive Simulations) @author Jonathan Olson <jonathan.olson@colorado.edu>

Class TinyStaticProperty

import { TinyStaticProperty } from 'scenerystack/axon';

Constructor

new TinyStaticProperty( value : T, onAccessAttempt : () => void )

Instance Methods

get() : T

Returns the value. Overridden to support onAccessAttempt.

set( value : T )

Don't set the value of a TinyStaticProperty!

isSettable() : boolean

Returns true if the value can be set externally. Static Property values should only be mutated, not set.

notifyListeners( oldValue : T | null )

Directly notifies listeners of changes.

Adds listener and calls it immediately. If listener is already registered, this is a no-op. The initial notification provides the current value for newValue and null for oldValue.

equalsValue( value : T ) : boolean

(protected)

Returns true if and only if the specified value equals the value of this property

Source Code

See the source for TinyStaticProperty.ts in the axon repository.