Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BaseController

BaseController is the common class used by all others controllers.

How to use

const target = { property: 1 }
const controller = group.add('property', target, {
// Displayed name
name: "My Custom Name",
// If target change, the controller will be updated (default is false)
listen: true
// Disabled the input, usefull for read only variable
disabled: true
})

Deal with events

Three kinds of events are emitted by all the controllers

  • input : Trigger when an input event is trigger by an HTMLInputElement
  • change : Trigger when an change event is trigger by an HTMLInputElement
  • update : Trigger when a modification is made on the target property. It's the most common way to use data-gui

Listen to event

Method one

myController.on('update', (newValue) => console.log(newValue))

Method two (using web-component and CustomEvent)

myController.addEventListener('update', ({ detail }) => console.log(detail))

Remove listener

You can use either off or removeEventListener to do so.

Hierarchy

Index

Constructors

Properties

listen: boolean = false

If true, the controller value will be updated automatically if target object is modified. Carefull: heavy use may reduce performance

group.add('someProperty', target, { listen: true })
disabled: boolean = false

If true, the controller will not be editable

name: string

Display name of a controller, defaultly equal to property.

group.add('someProperty', target, { name: 'Custom display name' })
property: string

property controlled in the target object

target: Object

source object in which the property key is defined

parent: BaseGroup

Methods

  • forceUpdate(): void
  • Manually update controller value in the form if target has changed

    Returns void

  • destroy(): void
  • Delete the controller

    Returns void

  • add(property: string, target?: Object, params?: any): void
  • Add a controller in the same Group of current controller

    Parameters

    • property: string
    • target: Object = undefined
    • params: any = undefined

    Returns void

  • valueOf(): any
  • Returns any

Generated using TypeDoc