Table of contents

Extends BindingUtil<TLArrowBinding>.

class ArrowBindingUtil extends BindingUtil<TLArrowBinding> {}

Constructor

from BindingUtil

Constructs a new instance of the BindingUtil class

Parameters
NameDescription

editor

Editor

Properties

migrations

static migrations: import('@tldraw/editor').TLPropsMigrations

props

static props: import('@tldraw/editor').RecordProps<TLArrowBinding>

type

static type: string

editor

from BindingUtil
editor: Editor

Methods

getDefaultProps()

getDefaultProps(): Partial<TLArrowBindingProps>

onAfterChange()

onAfterChange({ bindingAfter }: BindingOnChangeOptions<TLArrowBinding>): void
Parameters
NameDescription

{ bindingAfter }

BindingOnChangeOptions<TLArrowBinding>
Returns
void

onAfterChangeFromShape()

onAfterChangeFromShape({
  shapeAfter,
}: BindingOnShapeChangeOptions<TLArrowBinding>): void
Parameters
NameDescription

{ shapeAfter, }

BindingOnShapeChangeOptions<TLArrowBinding>
Returns
void

onAfterChangeToShape()

onAfterChangeToShape({
  binding,
}: BindingOnShapeChangeOptions<TLArrowBinding>): void
Parameters
NameDescription

{ binding }

BindingOnShapeChangeOptions<TLArrowBinding>
Returns
void

onAfterCreate()

onAfterCreate({ binding }: BindingOnCreateOptions<TLArrowBinding>): void
Parameters
NameDescription

{ binding }

BindingOnCreateOptions<TLArrowBinding>
Returns
void

onAfterDelete()

from BindingUtil

Called after a binding has been deleted. See BindingOnDeleteOptions for details.

onAfterDelete?(options: BindingOnDeleteOptions<Binding>): void
Parameters
NameDescription

options

BindingOnDeleteOptions<Binding>
Returns
void

onBeforeChange()

from BindingUtil

Called when a binding is about to be changed. See BindingOnChangeOptions for details.

Note that this only fires when the binding record is changing, not when the shapes associated change. Use BindingUtil.onAfterChangeFromShape and BindingUtil.onAfterChangeToShape for that.

You can optionally return a new binding to replace the one being changed - for example, to enforce constraints on the binding's props.

onBeforeChange?(options: BindingOnChangeOptions<Binding>): Binding | void
Parameters
NameDescription

options

BindingOnChangeOptions<Binding>
Returns
Binding | void

onBeforeCreate()

from BindingUtil

Called when a binding is about to be created. See BindingOnCreateOptions for details.

You can optionally return a new binding to replace the one being created - for example, to set different initial props.

onBeforeCreate?(options: BindingOnCreateOptions<Binding>): Binding | void
Parameters
NameDescription

options

BindingOnCreateOptions<Binding>
Returns
Binding | void

onBeforeDelete()

from BindingUtil

Called when a binding is about to be deleted. See BindingOnDeleteOptions for details.

onBeforeDelete?(options: BindingOnDeleteOptions<Binding>): void
Parameters
NameDescription

options

BindingOnDeleteOptions<Binding>
Returns
void

onBeforeDeleteFromShape()

from BindingUtil

Called before the shape referenced in a binding's fromId is about to be deleted. Use this with care - you may want to use BindingUtil.onBeforeIsolateToShape instead. See BindingOnShapeDeleteOptions for details.

onBeforeDeleteFromShape?(options: BindingOnShapeDeleteOptions<Binding>): void
Parameters
NameDescription

options

BindingOnShapeDeleteOptions<Binding>
Returns
void

onBeforeDeleteToShape()

from BindingUtil

Called before the shape referenced in a binding's toId is about to be deleted. Use this with care - you may want to use BindingUtil.onBeforeIsolateFromShape instead. See BindingOnShapeDeleteOptions for details.

onBeforeDeleteToShape?(options: BindingOnShapeDeleteOptions<Binding>): void
Parameters
NameDescription

options

BindingOnShapeDeleteOptions<Binding>
Returns
void

onBeforeIsolateFromShape()

onBeforeIsolateFromShape({
  binding,
}: BindingOnShapeIsolateOptions<TLArrowBinding>): void
Parameters
NameDescription

{ binding, }

BindingOnShapeIsolateOptions<TLArrowBinding>
Returns
void

onBeforeIsolateToShape()

from BindingUtil

Called before the shape referenced in a binding's toId is about to be isolated from the shape referenced in fromId. See BindingOnShapeIsolateOptions for discussion on what isolation means, and when/how to use this callback.

onBeforeIsolateToShape?(options: BindingOnShapeIsolateOptions<Binding>): void
Parameters
NameDescription

options

BindingOnShapeIsolateOptions<Binding>
Returns
void

onOperationComplete()

from BindingUtil

Called whenever a store operation involving this binding type has completed. This is useful for working with networks of related bindings that may need to update together.

onOperationComplete?(): void
Example
class MyBindingUtil extends BindingUtil<MyBinding> {
  changedBindingIds = new Set<TLBindingId>()

  onOperationComplete() {
    doSomethingWithChangedBindings(this.changedBindingIds)
    this.changedBindingIds.clear()
  }

  onAfterChange({ bindingAfter }: BindingOnChangeOptions<MyBinding>) {
    this.changedBindingIds.add(bindingAfter.id)
  }
}

TLSocketRoomArrowShapeTool