Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return (storeOrConfig, config) => {
if (typeof storeOrConfig === 'object' && !mobx.isObservable(storeOrConfig)) {
console.log('1')
return store => func(store, storeOrConfig);
}
console.log('calling func')
return func(storeOrConfig, config);
};
}
@action handleClick3 = () => {
let key = 'map2-' + this.map2.size ;
this.map2.set(key, true);
console.log('------ this is map2------');
console.log(this.map2.keys());
console.log(isObservable(this.map2.get('map2-1')));
console.log(isObservable(this.map2));
console.log(isObservableMap(this.map2));
};
function updateObservableValue(
oldV: any,
newV: any,
isDeepProp: undefined | ((pname: string) => boolean),
localObservables: LocalObservables
) {
if (isObservable(newV)) {
return newV
}
if (Array.isArray(newV)) {
return updateObservableArray(oldV, newV, localObservables)
}
if (isPlainObject(newV)) {
return updateObservableObject(oldV, newV, isDeepProp, localObservables)
}
if (newV instanceof Map) {
return updateObservableMap(oldV, newV, localObservables)
}
return newV
}
Object.keys(this.props).forEach(propName => {
const prop = this.props[propName]
if (isObservable(prop)) {
activate(prop)
this.autoRunList.push(autorun(() => this.cloneProp(propName, prop)))
} else {
_.forEach(prop, (value, key) => {
activate(value)
this.autoRunList.push(autorun(() => this.cloneProp(`${propName}.${key}`, value)))
})
}
})
},
constructor(
/**
* SubItems can be any Validatable
*/
public $: TValue
) {
this.mode = isArrayLike($) ? 'array' : isMapLike($) ? 'map' : 'object';
/** If they didn't send in something observable make the local $ observable */
if (!isObservable(this.$)) {
this.$ = observable(this.$);
}
}
type: Object,
},
},
};
const schema = new Schema(inputDefinition);
const item = new TestItemClass();
schema.establishObservables(item);
expect(isObservable(item, 'brand')).toBe(true);
expect(isObservable(item, 'price')).toBe(false);
expect(isObservable(item.seats, 'front')).toBe(false);
expect(isObservable(item.seats.deeper, 'test')).toBe(true);
expect(isObservable(item.seats.deeper, 'arr')).toBe(true);
expect(isObservableArray(item.seats.deeper.arr)).toBe(true);
expect(isObservable(item.seats.deeper.evenDeeper, 'property1')).toBe(false);
expect(isObservable(item.seats.deeper.evenDeeper, 'property2')).toBe(true);
done();
});
function activate(store) {
isObservable(store)
const descriptors = Object.getOwnPropertyDescriptors(store)
_.forEach(descriptors, (descriptor, name) => {
if (descriptor.get && !descriptor.enumerable) {
descriptor.enumerable = true
Object.defineProperty(store, name, descriptor)
}
})
}
MobxPathObjectBinder.prototype.setValue = function (path, value) {
if (path === undefined)
return;
var cursorPath = utils_1.castPath(path);
if (cursorPath.length === 0)
return;
var parent = this.getParent(cursorPath);
var property = cursorPath[cursorPath.length - 1];
if (mobx_1.isObservable(parent, property)) {
parent[property] = value;
return;
}
this.setValueAsObservable(parent, property, value);
};
MobxPathObjectBinder.prototype.getParent = function (cursorPath) {
changeLiked(track: ITrack, liked: boolean) {
if (!isObservable(track.isLiked)) {
extendObservable(track, 'isLiked');
}
track.isLiked = liked;
}