Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Signal<Arg>

An object representing an event.

Functions can be connected to the signal object, after which they will get called when the signal is emitted. The tiled module provides several useful signals, like tiled.assetAboutToBeSaved.

Properties usually will have related signals which can be used to detect changes to that property, but most of those are currently not implemented.

To connect to a signal, call its connect function and pass in a function object. In the following example, newly created maps automatically get their first tile layer removed:

tiled.assetCreated.connect(function(asset) {
    if (asset.layerCount > 0) {
        asset.removeLayerAt(0)
        tiled.log("assetCreated: Removed automatically added tile layer.")
    }
})

In some cases it will be necessary to later disconnect the function from the signal again. This can be done by defining the function separately and passing it into the disconnect function:

function onAssetCreated(asset) {
    // Do something...
}

tiled.assetCreated.connect(onAssetCreated)
// ...
tiled.assetCreated.disconnect(onAssetCreated)

Type parameters

  • Arg

Hierarchy

  • Signal

Index

Methods

connect

  • connect(callback: (arg: Arg) => void): void

disconnect

  • disconnect(callback: (arg: Arg) => void): void

Generated using TypeDoc