How to use the bobril.isArray function in bobril

To help you get started, we’ve selected a few bobril examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bobril / bobx / index.ts View on Github external
export function observableProp(obj: T, key: K): b.IProp {
    if (obj == null) throw new Error("observableProp parameter is " + obj);
    let bobx = ((obj as any) as IAtom).$bobx;
    if (bobx === undefined) throw new Error("observableProp parameter is not observable: " + obj);
    if (bobx === ObservableMapMarker) throw new Error("observableProp parameter is observableMap");
    if (b.isArray(bobx)) {
        // Does this pays off to cache and/or inline?
        return (value?: any) => {
            if (value !== undefined) {
                obj[key] = value;
            }
            return obj[key];
        };
    }
    if (Object.getPrototypeOf(bobx) === undefined) {
        return (bobx[key] as ObservableValue).prop();
    }
    bobx = asObservableClass(obj);
    let val = bobx[key];
    if (val === undefined) {
        obj[key]; // Has side effect to create ObservableValue
        val = bobx[key]!;
github bobril / bobx / index.js View on Github external
function isArrayLike(thing) {
    return b.isArray(thing) || isObservableArray(thing);
}
b.setIsArrayVdom(isArrayLike);
github bobril / bobx / index.ts View on Github external
function isArrayLike(thing: any): thing is any[] {
    return b.isArray(thing) || isObservableArray(thing);
}
github bobril / bobril-m / src / menu.ts View on Github external
postRender(focused: boolean) {
        if (this.parent == undefined) {
            this._clear();
            return;
        }
        let ch = this.parent.children;
        if (!b.isArray(ch)) {
            this._clear();
            return;
        }
        const selectable = this.selectable;
        selectable.length = 0;
        for (let i = 0; i < ch.length; i++) {
            let c = ch[i].ctx as IMenuItemControllerChild;
            if (c.owner == this && !c._disabled) {
                selectable.push(c);
            }
        }
        this._update(focused);
    }
github bobril / bobx / index.js View on Github external
function isObservableArray(thing) {
    return isObject(thing) && b.isArray(thing.$bobx);
}
exports.isObservableArray = isObservableArray;
github bobril / bobx / index.js View on Github external
function deepStructEnhancer(newValue, oldValue) {
    if (deepEqual(newValue, oldValue))
        return oldValue;
    if (newValue == null)
        return newValue;
    if (isObservable(newValue))
        return newValue;
    if (b.isArray(newValue))
        return new ObservableArray(newValue, deepStructEnhancer);
    if (isES6Map(newValue))
        return new ObservableMap(newValue, deepStructEnhancer);
    if (isPlainObject(newValue)) {
        var res = Object.create(Object.getPrototypeOf(newValue));
        var behind = asObservableObject(res);
        for (var key in newValue) {
            defineObservableProperty(res, behind, key, newValue[key], deepStructEnhancer);
        }
        return res;
    }
    return newValue;
}
function refStructEnhancer(newValue, oldValue) {
github bobril / bobx / index.ts View on Github external
export function isObservableArray(thing: any): thing is IObservableArray {
    return isObject(thing) && b.isArray(thing.$bobx);
}
github bobril / bobx / index.ts View on Github external
function deepEnhancer(newValue: T, oldValue: T | undefined): T {
    if (newValue === oldValue) return oldValue;
    if (newValue == null) return newValue;
    if (isObservable(newValue)) return newValue;
    if (b.isArray(newValue)) return new ObservableArray(newValue as any, deepEnhancer) as any;
    if (isES6Map(newValue)) return new ObservableMap(newValue, deepEnhancer) as any;
    if (isPlainObject(newValue)) {
        let res = Object.create(Object.getPrototypeOf(newValue));
        let behind = asObservableObject(res);
        for (let key in newValue as IKeyValueMap) {
            defineObservableProperty(res, behind, key, (newValue as IKeyValueMap)[key], deepEnhancer);
        }
        return res;
    }
    return newValue;
}