• Makes any object an observable object

    Example

    const obj = {
    a: 1,
    b: {
    c: 5
    }
    }

    const obsObj = Jodit.modules.observable(obj);
    console.log(obj === obsObj); // true
    obsObj.on('change', () => {
    console.log('Object changed');
    });
    obsObj.on('change.a', () => {
    console.log('Key a changed');
    });
    obsObj.on('change.b.c', () => {
    console.log('Key b.c changed');
    });

    obj.a = 6;
    // Object changed
    // Key a changed

    obj.b = {c: 6}
    // Object changed

    obj.b.c = 8
    // Object changed
    // Key b.c changed

    Type Parameters

    Parameters

    • obj: T

    Returns O

Jodit PRO

If you like Jodit - try Jodit PRO