Skip to content

createObservableArray

Overview

createObservableArray conforms to the Proxy interface, which is polluted with any types. Therefore we disable this rule for this file. /* eslint-disable typescript-eslint/no-explicit-any */ Creates an object that has the same API as an Array, but also supports notifications and PhET-iO. When an item is added or removed, the lengthProperty changes before elementAddedEmitter or elementRemovedEmitter emit.

@author Sam Reid (PhET Interactive Simulations)

Type ObservableArrayOptions

import type { ObservableArrayOptions } from 'scenerystack/axon';
  • length?: number
  • elements?: T[]
  • hasListenerOrderDependencies?: boolean
  • elementAddedEmitterOptions?: StrictOmit<EmitterOptions, "tandem" | "parameters" | "phetioReadOnly">
    Options for the array's child elements. Omitted options are the responsibility of the array.
  • elementRemovedEmitterOptions?: StrictOmit<EmitterOptions, "tandem" | "parameters" | "phetioReadOnly">
  • lengthPropertyOptions?: StrictOmit<NumberPropertyOptions, "tandem" | "numberType" | "phetioReadOnly">
  • & PhetioObjectOptions

Source Code

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