SheetXL - v1.0.2
    Preparing search index...

    Interface Options

    Additional options for a listener.

    interface Options {
        once?: boolean;
        transactional?: boolean;
    }
    Index
    once?: boolean

    If true, the listener will be removed after the first time it is called.

    false;
    
    transactional?: boolean

    Whether the listener takes part in the operation that notifies it.

    true when the listener is added through the object a batch hands its callback (IWorkbook.doBatch, IWorksheet.doBatch, ICellRange.doBatch), and false otherwise - however long a batch stays open.

    A script, or code acting for one, adds its listeners through its batch and takes part by default. A view, or anything else watching the document, adds them the ordinary way and is an observer by default. Neither needs to set this.

    A participant hears what is announced while an operation is under way. A worksheet announces each write as it is made (IWorksheet.Events.onDataChange, onStyleChange, onMergesChange, onSpillsChange), so a participant hears each write and an observer hears the operation once, every write merged. An event that is announced only once the operation has landed never reaches a participant; to hear one from a batch, add the listener with transactional: false.

    A transactional listener:

    • is told inline, inside the operation, so anything it writes joins that same commit, and is told during an undo or a redo for the same reason;
    • hears nothing announced outside an operation;
    • is part of the document: the operation that added it removes it on undo and puts it back on redo.

    A non-transactional listener:

    • is told once per operation, after it has landed, however many times the operation notified, and not at all if the operation is rolled back;
    • is told at once when there is no operation, and at once during an undo or a redo;
    • survives an undo, since it is not part of the document.