Skip to content

on 'op' callback firing multiple times per each submitOp #147

Open
@mdelbuono

Description

@mdelbuono

Hi I have the following code:

shareDoc.on('op', (ops, source) => {
    for (let op of ops) {
        this._dispatchOperation(op);
    }
});

The _dispatchOperation method gets called 4 times for each submitOp with the same ops object and source=true.

Is this by design or is it a bug?

In my case it is not what I want, therefore I modified the code as follows.

this._lastOps = null;
shareDoc.on('op', (ops, source) => {
    if (lodash.isEqual(ops, this._lastOps)) return;
    this._lastOps = ops;
    for (let op of ops) {
        this._dispatchOperation(op);
    }
});

Is this ok or the three op notifications that I am ignoring may be important?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions