Sha256: af88f992144eab9052d47564dfa01a220be0585717a4a60a63bb919e8f2e95b3

Contents?: true

Size: 788 Bytes

Versions: 2

Compression:

Stored size: 788 Bytes

Contents

import { meta as metaFor, peekMeta } from 'ember-meta';
import { makeChainNode } from './chains';
export function watchPath(obj, keyPath, meta) {
    let m = meta === undefined ? metaFor(obj) : meta;
    let counter = m.peekWatching(keyPath);
    m.writeWatching(keyPath, counter + 1);
    if (counter === 0) {
        // activate watching first time
        m.writableChains(makeChainNode).add(keyPath);
    }
}
export function unwatchPath(obj, keyPath, meta) {
    let m = meta === undefined ? peekMeta(obj) : meta;
    if (m === undefined) {
        return;
    }
    let counter = m.peekWatching(keyPath);
    if (counter > 0) {
        m.writeWatching(keyPath, counter - 1);
        if (counter === 1) {
            m.writableChains(makeChainNode).remove(keyPath);
        }
    }
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
discourse-ember-source-3.5.1.1 dist/es/ember-metal/lib/watch_path.js
discourse-ember-source-3.5.1.0 dist/dist/es/ember-metal/lib/watch_path.js