From 2815da82998ff02fb8a0f905630a300526aad792 Mon Sep 17 00:00:00 2001 From: Sam Reid Date: Tue, 14 Feb 2023 15:50:10 -0700 Subject: [PATCH] Move LinkableElement to a top-level type, improve documentation, use LinkableProperty and LinkableReadOnlyProperty, see https://github.com/phetsims/axon/issues/414 --- js/LinkableElement.ts | 11 +++++++++++ js/PhetioObject.ts | 6 ++---- 2 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 js/LinkableElement.ts diff --git a/js/LinkableElement.ts b/js/LinkableElement.ts new file mode 100644 index 00000000..347e2b58 --- /dev/null +++ b/js/LinkableElement.ts @@ -0,0 +1,11 @@ +// Copyright 2023, University of Colorado Boulder +import PhetioObject from './PhetioObject.js'; + +/** + * When linking a PhET-iO Element via PhetioObject.addLinkedElement it uses this type. + * @see PhetioObject.addLinkedElement + * + * @author Sam Reid (PhET Interactive Simulations) + */ +type LinkableElement = Pick; +export default LinkableElement; \ No newline at end of file diff --git a/js/PhetioObject.ts b/js/PhetioObject.ts index e84dd9ae..cfb6f07c 100644 --- a/js/PhetioObject.ts +++ b/js/PhetioObject.ts @@ -28,6 +28,7 @@ import tandemNamespace from './tandemNamespace.js'; import IOType from './types/IOType.js'; import IntentionalAny from '../../phet-core/js/types/IntentionalAny.js'; import Disposable, { DisposableOptions } from '../../axon/js/Disposable.js'; +import LinkableElement from './LinkableElement.js'; // constants const PHET_IO_ENABLED = Tandem.PHET_IO_ENABLED; @@ -139,8 +140,6 @@ export type PhetioObjectOptions = SelfOptions & ParentOptions; type PhetioObjectMetadataKeys = keyof ( StrictOmit ) | 'phetioType'; export type PhetioObjectMetadataInput = Pick; -export type LinkableElement = Pick; - class PhetioObject extends Disposable { // assigned in initializePhetioObject - see docs at DEFAULTS declaration @@ -580,8 +579,7 @@ class PhetioObject extends Disposable { * association which is rendered in Studio as a "symbolic" link or hyperlink. Many common code UI elements use this * automatically. To keep client sites simple, this has a graceful opt-out mechanism which makes this function a * no-op if either this PhetioObject or the target PhetioObject is not instrumented. - * @param element - the target element. Must be instrumented for a LinkedElement to be created-- - * - otherwise it gracefully opts out + * @param element - the target element. Must be instrumented for a LinkedElement to be created-- otherwise gracefully opts out * @param [options] */ public addLinkedElement( element: LinkableElement, options?: LinkedElementOptions ): void {