BindingUtil
See source codeTable of contents
abstract class BindingUtil<
Binding extends TLUnknownBinding = TLUnknownBinding,
> {}Constructor
Constructs a new instance of the BindingUtil class
Parameters
| Name | Description |
|---|---|
|
Properties
migrations
static migrations?: TLPropsMigrationsprops
static props?: RecordProps<TLUnknownBinding>type
The type of the binding util, which should match the binding's type.
static type: stringeditor
editor: EditorMethods
getDefaultProps( )
Get the default props for a binding.
abstract getDefaultProps(): Partial<Binding['props']>onAfterChange( )
Called after a binding has been 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.
onAfterChange?(options: BindingOnChangeOptions<Binding>): voidParameters
| Name | Description |
|---|---|
| |
Returns
voidonAfterChangeFromShape( )
Called after the shape referenced in a binding's fromId is changed. Use this to propagate
any changes to the binding itself or the other shape as needed. See
BindingOnShapeChangeOptions for details.
onAfterChangeFromShape?(options: BindingOnShapeChangeOptions<Binding>): voidParameters
| Name | Description |
|---|---|
| |
Returns
voidonAfterChangeToShape( )
Called after the shape referenced in a binding's toId is changed. Use this to propagate any
changes to the binding itself or the other shape as needed. See
BindingOnShapeChangeOptions for details.
onAfterChangeToShape?(options: BindingOnShapeChangeOptions<Binding>): voidParameters
| Name | Description |
|---|---|
| |
Returns
voidonAfterCreate( )
Called after a binding has been created. See BindingOnCreateOptions for details.
onAfterCreate?(options: BindingOnCreateOptions<Binding>): voidParameters
| Name | Description |
|---|---|
| |
Returns
voidonAfterDelete( )
Called after a binding has been deleted. See BindingOnDeleteOptions for details.
onAfterDelete?(options: BindingOnDeleteOptions<Binding>): voidParameters
| Name | Description |
|---|---|
| |
Returns
voidonBeforeChange( )
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 | voidParameters
| Name | Description |
|---|---|
| |
Returns
Binding | voidonBeforeCreate( )
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 | voidParameters
| Name | Description |
|---|---|
| |
Returns
Binding | voidonBeforeDelete( )
Called when a binding is about to be deleted. See BindingOnDeleteOptions for details.
onBeforeDelete?(options: BindingOnDeleteOptions<Binding>): voidParameters
| Name | Description |
|---|---|
| |
Returns
voidonBeforeDeleteFromShape( )
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>): voidParameters
| Name | Description |
|---|---|
| |
Returns
voidonBeforeDeleteToShape( )
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>): voidParameters
| Name | Description |
|---|---|
| |
Returns
voidonBeforeIsolateFromShape( )
Called before the shape referenced in a binding's fromId is about to be isolated from the
shape referenced in toId. See BindingOnShapeIsolateOptions for discussion on what
isolation means, and when/how to use this callback.
onBeforeIsolateFromShape?(
options: BindingOnShapeIsolateOptions<Binding>
): voidParameters
| Name | Description |
|---|---|
| |
Returns
voidonBeforeIsolateToShape( )
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>): voidParameters
| Name | Description |
|---|---|
| |
Returns
voidonOperationComplete( )
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?(): voidExample
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)
}
}