How to use the mobx.isObservable function in mobx

To help you get started, we’ve selected a few mobx 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 BrascoJS / delorean / src / getDecorator.js View on Github external
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);
  };
}
github ckinmind / mobx-share / src / page-mobx / p6.js View on Github external
@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));
    };
github mobxjs / mobx-utils / src / updateableObservable.ts View on Github external
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
}
github jamieYou / weapp-starter-kit / src / store / observer.js View on Github external
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)))
          })
        }
      })
    },
github formstate / formstate / src / core / formState.ts View on Github external
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.$);
    }
  }
github Hypheme / harmonized.js / src / Schema.spec.js View on Github external
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();
  });
github jamieYou / weapp-starter-kit / src / store / observer.js View on Github external
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)
    }
  })
}
github rsamec / react-binding / dist / lib / MobxProvider.js View on Github external
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) {
github dive2Pro / SoundCloudMobx / src / store / TrackStore.ts View on Github external
changeLiked(track: ITrack, liked: boolean) {
    if (!isObservable(track.isLiked)) {
      extendObservable(track, 'isLiked');
    }
    track.isLiked = liked;
  }