SheetXL - v1.0.2
    Preparing search index...

    Interface ListenerOptions

    Options to control which events trigger a listener. By default, all event types will trigger the listener. Setting any of these options to true will prevent the listener from being called for that event type.

    interface ListenerOptions {
        anchor?: IAnchored.Type;
        edits?: boolean;
        ignoreAddressChanges?: boolean;
        ignoreDataChanges?: boolean;
        once?: boolean;
        transactional?: boolean;
        weakly?: boolean;
    }
    Index
    anchor?: IAnchored.Type

    How the listened range follows rows and columns inserted or deleted around it.

    IAnchored.Type.TwoCell

    • TwoCell: the range follows its cells, as a formula reference does. An insert above it moves it down, a delete inside it shrinks it, and deleting all of its cells makes it #REF!. Each move is an 'address' event.
    • OneCell: the top-left follows its cell and the extent is kept, as a picture anchored to one cell. Deleting the top-left cell leaves the range where it is.
    • Absolute: the range never moves. It names the same addresses whatever is inserted or deleted, so it never has an 'address' event. This is what a view listening to the rows it shows wants: the cells on screen, not the cells that were there when it subscribed.
    edits?: boolean

    Whether an 'address' event carries the edits that changed the range's cells (Event.getEdits).

    false
    

    With it, the listener is also told of a cut that takes only some of its cells: the range itself stays (a cut moves a reference only when it takes all of it), but the cells it names were moved, and the event says where.

    ignoreAddressChanges?: boolean

    If true, the listener will not be called when the range's address changes (due to row/column insert/delete, moves, or a rename of the sheet a qualified range names). The range still follows its cells; see anchor for a range that should not.

    false
    
    ignoreDataChanges?: boolean

    If true, the listener will not be called when the data within the range changes.

    false
    
    once?: boolean

    If true then will auto deregister once fired.

    transactional?: boolean

    Whether the listener takes part in the operations that change its range.

    true when the listener is added through a range reached through the object a batch hands its callback (IWorkbook.doBatch, IWorksheet.doBatch, doBatch), and false otherwise.

    A transactional listener (a participant):

    • added through a batch, is told as each operation of that batch is made, before the operation returns, with what that operation changed. It is not told again when the batch lands;
    • added any other way, is told once at the end of each operation, before it is committed;
    • writes into the same commit as the change it was told of, so one undo takes back both;
    • is never told of an undo or a redo, and is removed by undoing the operation that added it. If its batch fails, it is told nothing more and goes with the batch.

    A non-transactional listener (an observer) is told once, after the operation has landed, with everything the operation changed in its range, and not at all if the operation is rolled back. What it writes is an operation of its own. It is told of an undo or a redo ('restore'), and it survives them.

    await workbook.doBatch(async (_commit, wb) => {
    const total = wb.getSelectedWorksheet()!.getRange('B1');
    const input = wb.getSelectedWorksheet()!.getRange('A1');
    input.addListener(() => total.setValue((input.getValue() as number) * 2)); // a participant
    input.setValue(21);
    total.getValue(); // 42
    });
    weakly?: boolean

    If true then the listener will be weakly and will be auto removed it the listener is gc'ed.

    false