How to use the mobx-state-tree.getEnv function in mobx-state-tree

To help you get started, we’ve selected a few mobx-state-tree 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 heartexlabs / label-studio / src / stores / CompletionStore.js View on Github external
_updateServerState(state) {
      let appStore = getParent(self, 3);
      let url = "/api/tasks/" + appStore.task.id + "/completions/" + self.pk + "/";

      getEnv(self).patch(url, JSON.stringify(state));
    },
github charlessolar / eShopOnContainersDDD / src / Web / src / app / parts / administration / models / brands.ts View on Github external
const list = flow(function*(term?: string, id?: string) {
      const request = new DTOs.ListCatalogBrands();

      request.term = term;
      request.id = id;

      self.loading = true;
      try {
        const client = getEnv(self).api as ApiClientType;
        const results: DTOs.PagedResponse = yield client.paged(request);

        results.records.forEach(record => {
          self.entries.put(record);
        });
      } catch (error) {
        debug('received http error: ', error);
      }
      self.loading = false;
    });
    const add = (brand: BrandType) => {
github grafana / grafana / public / app / stores / TeamsStore / TeamsStore.ts View on Github external
addGroup: flow(function* load(groupId: string) {
      const backendSrv = getEnv(self).backendSrv;
      yield backendSrv.post(`/api/teams/${self.id}/groups`, { groupId: groupId });
      self.groups.set(
        groupId,
        TeamGroup.create({
          teamId: self.id,
          groupId: groupId,
        })
      );
    }),
github charlessolar / eShopOnContainersDDD / src / Web / src / app / parts / administration / stores / dashboard.ts View on Github external
const requestByState = new DTOs.OrderingSalesByState();

      if (self.period && self.period.from) {
        requestChart.from = self.period.from;
        requestWeekOverWeek.from = self.period.from;
        requestByState.from = self.period.from;
      }
      if (self.period && self.period.to) {
        requestChart.to = self.period.to;
        requestWeekOverWeek.to = self.period.to;
        requestByState.to = self.period.to;
      }

      self.loading = true;
      try {
        const client = getEnv(self).api as ApiClientType;

        const results: [DTOs.PagedResponse, DTOs.PagedResponse, DTOs.PagedResponse] =
          yield Promise.all([
            client.paged(requestChart),
            client.paged(requestWeekOverWeek),
            client.paged(requestByState)
          ]);

        self.chart.replace(results[0].records.map(x => [x.id, x]));
        self.weekOverWeek.replace(results[1].records.map(x => [x.id, x]));
        self.byState.replace(results[2].records.map(x => [x.id, x]));
       } catch (error) {
        debug('received http error: ', error);
        throw error;
      }
      self.loading = false;
github heartexlabs / label-studio / src / stores / RegionStore.js View on Github external
deleteRegion(region) {
      const arr = self.regions;

      for (let i = 0; i < arr.length; i++) {
        if (arr[i] === region) {
          arr.splice(i, 1);
        }
      }

      getEnv(self).onEntityDelete(region);
    },
github charlessolar / eShopOnContainersDDD / src / Web / src / app / parts / administration / stores / types.ts View on Github external
const submit = flow(function*() {
      const request = new DTOs.AddCatalogType();

      request.typeId = self.id;
      request.type = self.type;

      try {
        const client = getEnv(self).api as ApiClientType;
        const result: DTOs.CommandResponse = yield client.command(request);

      } catch (error) {
        debug('received http error: ', error);
        throw error;
      }
    });
github charlessolar / eShopOnContainersDDD / src / Web / src / app / parts / administration / stores / brands.ts View on Github external
const submit = flow(function*() {
      const request = new DTOs.AddCatalogBrand();

      request.brandId = self.id;
      request.brand = self.brand;

      try {
        const client = getEnv(self).api as ApiClientType;
        const result: DTOs.CommandResponse = yield client.command(request);

       } catch (error) {
        debug('received http error: ', error);
        throw error;
      }
    });