How to use the extendObservable function from mobx

Find comprehensive JavaScript mobx.extendObservable code examples handpicked from public code repositorys.

27
28
29
30
31
32
33
34
35
36
constructor() {
  this.contentsDir = join(__dirname, '..', '..', 'static', 'contents')
  this.items = {}

  /** Extend the store with observable and computed properties. */
  extendObservable(this, {
    contents: {},
    updatedItems: [],
    updateInProgress: false,
    updateAgain: false,
fork icon1
star icon3
watch icon2

+ 12 other calls in file

102
103
104
105
106
107
108
109
110
111
```javascript
var m = require('mobx')

function Folder(parent, name) {
        this.parent = parent;
        m.extendObservable(this, {
                name: name,
                children: m.observable.shallow([]),
        });
}
fork icon227
star icon0
watch icon21

+ 27 other calls in file

1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
    invariant(!_this3.__attributes.includes(currentRel), 'Cannot define `' + currentRel + '` as both an attribute and a relation. You probably need to remove the attribute.');
    if (!_this3.__activeCurrentRelations.includes(currentRel)) {
        _this3.__activeCurrentRelations.push(currentRel);
    }
});
mobx.extendObservable(this, lodash.mapValues(relModels, function (otherRelNames, relName) {
    var RelModel = relations[relName];
    invariant(RelModel, 'Specified relation "' + relName + '" does not exist on model.');
    var options = { relations: otherRelNames };
    if (RelModel.prototype instanceof Store) {
fork icon13
star icon30
watch icon11

+ 3 other calls in file

65
66
67
68
69
70
71
72
73
74
        return utils_1.baseGet(this.source, parentPath);
    };
    MobxPathObjectBinder.prototype.setValueAsObservable = function (parent, property, value) {
        var newProps = {};
        newProps[property] = value;
        mobx_1.extendObservable(parent, newProps);
    };
    return MobxPathObjectBinder;
}());
Object.defineProperty(exports, "__esModule", { value: true });
fork icon0
star icon48
watch icon4

+ 35 other calls in file

737
738
739
740
741
742
743
744
745
746
    if (!this.__activeCurrentRelations.includes(currentRelation)) {
        this.__activeCurrentRelations.push(currentRelation);
    }
});
// extendObservable where we omit the fields that are already created from other relations
mobx_1.extendObservable(this, lodash_1.mapValues(lodash_1.omit(relationModels, Object.keys(relationModels).filter(rel => !!this[rel])), (otherRelationNames, relationName) => {
    const RelationModel = relations[relationName];
    if (!RelationModel) {
        throw Error(`Specified relation "${relationName}" does not exist on model.`);
    }
fork icon0
star icon0
watch icon0