Skip to content

PhetioDataHandler

Overview

Helper type that supports a parameters member. This is mostly useful for PhET-iO instrumented sub-class to use that takes a variable number of parameters in their IOType. With this function you gain parameter validation, PhET-iO documentation, and data stream support.

@author Sam Reid (PhET Interactive Simulations) @author Michael Kauzmann (PhET Interactive Simulations)

Class PhetioDataHandler

import { PhetioDataHandler } from 'scenerystack/tandem';

Constructor

new PhetioDataHandler( providedOptions? : PhetioDataHandlerOptions )

Instance Methods

validateArguments( ...args : T )

(protected)

Validate that provided args match the expected schema given via options.parameters.

getValidationErrors( ...args : T ) : Array<string | null>

Validate that provided args match the expected schema given via options.parameters.

getPhetioData( ...args : T ) : null | Record<string, unknown>

Gets the data that will be emitted to the PhET-iO data stream, for an instrumented simulation. @returns the data, keys dependent on parameter metadata

Type Parameter

import type { Parameter } from 'scenerystack/tandem';
  • name?: string
  • phetioDocumentation?: string
  • phetioPrivate?: boolean
  • & Validator

Type PhetioDataHandlerOptions

Use each subtype should provide its own phetioOuterType. That coupled with parameter IOTypes will result in the phetioType. Don't pass this in!

import type { PhetioDataHandlerOptions } from 'scenerystack/tandem';
  • parameters?: Parameter[]
    The parameters to the emit method that will be called. See PARAMETER_KEYS for a list of legal keys, their types, and documentation.
  • phetioOuterType: ( t: IOType[] ) => IOType
  • hasListenerOrderDependencies?: boolean
  • & StrictOmit<PhetioObjectOptions, "phetioType">

Source Code

See the source for PhetioDataHandler.ts in the tandem repository.