How to use the makeObservable function from mobx

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

2
3
4
5
6
7
8
9
10
11
12
13
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }


var _require = require('mobx'),
    autorun = _require.autorun,
    observable = _require.observable,
    makeObservable = _require.makeObservable;


console.log(observable, 'observable'); // class A{
//     @observable state = {
//         key:10
fork icon0
star icon1
watch icon0

1
2
3
4
5
6
7
8
9
10
11
const CodingRelatedSet = require("./CodingRelatedSet");


class ModifiableCodingRelatedSet extends CodingRelatedSet {
  constructor(id, noOfQs) {
    super(id, noOfQs);
    makeObservable(this, {
      resetCode: flow,
      saveCode: flow,
    });
  }
fork icon0
star icon0
watch icon0

+ 2 other calls in file

2
3
4
5
6
7
8
9
10
11
12
13
export class UserStore {
    @observable currentUserData = null;
    @observable allUsers = null;


    constructor() {
        makeObservable(this);
    }


    @flow *getUserData() {
        const response = yield fetch('http://localhost:8081/api/users/user', {
fork icon0
star icon0
watch icon0