@hmiproject/helio-sdk
    Preparing search index...

    Function createDynamicProperty

    • Creates a HELIO Dynamic Property.

      Dynamic properties are configurable values that can change dynamically over time and support write operations.

      Note: New dynamic properties need to be added to the extension's library (see createLibraryExtension) to become active in HELIO.

      Type Parameters

      Parameters

      • namespace: Namespace

        Namespace for uniquely addressing this dynamic property.

      • options: {
            category?: string;
            description?: string;
            icon?: IconRef;
            id?: string;
            name: string;
            propsSchema: Schema;
            valueTypes?: PropertyValueType[];
            writable: boolean;
            useDynamicProperty(
                props: CurrentSchemaValues<Schema>,
            ): UseDynamicPropertyResult;
        }
        • Optionalcategory?: string

          Optional category for grouping this dynamic property in the HELIO IDE.

        • Optionaldescription?: string

          Description of this dynamic property that will appear in the IDE.

        • Optionalicon?: IconRef

          Optional icon to identify this dynamic property in the HELIO IDE.

          { name: 'Dinosaur' }
          
        • Optionalid?: string

          Internal ID of the dynamic property. This uniquely identifies the dynamic property within the extension and should never change. If this property is omitted, the dynamic property will be referenced by its name.

        • name: string

          Human-readable name of the dynamic property as it will appear in the HELIO IDE.

          Note: If no explicit id is provided, this value will also be used to create a unique id for the dynamic property.

          Changing the name in an extension update will break dynamic property references in existing projects.

          If you need to change the name, make sure to provide an id with the old name to ensure a smooth migration.

          Migrating dynamic property name.

          {
          name: 'New Dynamic Property Name',
          id: 'Old Dynamic Property Name',
          // ...other `createDynamicProperty` options...
          }
        • propsSchema: Schema

          Schema containing the properties this dynamic property accepts, created using the createPropsSchema function.

        • OptionalvalueTypes?: PropertyValueType[]

          What kinds of values does this dynamic property provide?

          This restricts the contexts in which the dynamic property is available. For example, dynamic properties that can produce strings can be used as labels, in outputs, etc.

          Dynamic Property can produce scalar values like strings, numbers, booleans, dates, etc.

          ['PrimitiveValue']
          

          Dynamic Property can produce either strings or numbers.

          ['String', 'Number']
          

          Dynamic Property can produce image URLs.

          ['Image']
          
          ['*']
          
        • writable: boolean

          Does this dynamic property support write operations?

          If set to false, elements like inputs will be automatically disabled when receiving values from this dynamic property.

          Note that a dynamic property might support writing but still want to dynamically enable/disable write access due to other factors. This can be done using the UseDynamic PropertyResult.canWrite | canWrite property returned from implementation of CreateDynamic PropertyOptions.useDynamic Property.

          UseDynamic PropertyResult.canWrite

        • useDynamicProperty: function

      Returns CreateDynamicPropertyResult<Schema>

      1.0.0

      Create a new dynamic property

      const property = createDynamicProperty(namespace, {
      name: 'Basic Property',
      propsSchema: createPropsSchema().initial({}),
      writable: false,
      valueTypes: ['NumericValue'],

      useDynamicProperty(_props) {
      return {
      valueType: values.Number(),
      value: 123,
      displayValue: '123',
      canRead: true,
      canWrite: false,
      };
      },
      });