dynamic-forms / Class

InsertArrayItemEvent

Generic types:TTemplate
Implements:FormEvent

Event dispatched to insert a new item at a SPECIFIC INDEX in an array field.

Use this when you need precise control over where the new item appears. For simpler operations, use {@link AppendArrayItemEvent} or {@link PrependArrayItemEvent}.

Constructor

No documentation has been provided.

Presentation
constructor(
	readonly arrayKey: string, 
	readonly index: number, 
	readonly template: TTemplate
): InsertArrayItemEvent<TTemplate>;
Parameters
NameTypeDescription
r
arrayKey
string
r
index
number
r
template
TTemplate

Properties

NameTypeDescription
type
r
implements FormEvent
"insert-array-item"

Example usage

// Object item: insert { name } object at index 2
eventBus.dispatch(arrayEvent('contacts').insertAt(2, [
  { key: 'name', type: 'input', label: 'Name' }
]));

// Primitive item: insert single value at index 2
eventBus.dispatch(arrayEvent('tags').insertAt(2,
  { key: 'tag', type: 'input', label: 'Tag' }
));