How to use the mobx.when 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 aksonov / statem / test / gen.js View on Github external
it("redirect to promo scene", function(done){
    statem.start();
    expect(statem.promoScene.active).to.be.false;
    when (()=>statem.promoScene.active, done);
  });
  // it("expect login scene with history", function(done){
github rate-engineering / rate3-monorepo / packages / demo / identity / src / pages / UserMain.js View on Github external
);
        this.props.RootStore.userStore.registryContract = contract;
        window.registryContract = contract;
      },
    );
    when(
      () => this.props.RootStore.userStore.userAddr && this.props.RootStore.finishInitMetamaskNetwork,
      () => {
        this.props.RootStore.userStore.resetClaimLists();
        this.props.RootStore.userStore.populateClaimLists();
        this.props.RootStore.userStore.getValidClaims();
      },
    );

    // Initilize Fixed Account, get claims from smart contract
    when(
      () => this.props.RootStore.userStore.isOnFixedAccount && this.props.RootStore.finishInitNetwork,
      () => {
        const contract = new window.web3.eth.Contract(
          identityRegistryJson.abi,
          this.props.RootStore.userStore.registryContractAddr,
        );
        this.props.RootStore.userStore.registryContract = contract;
        window.registryContract = contract;

        this.props.RootStore.userStore.populateClaimLists();
        this.props.RootStore.userStore.getValidClaims();
      },
    );

    when(
      () => this.props.RootStore.commonStore.isWalletSetupDone,
github binary-com / binary-static / src / javascript / app_2 / Stores / client-store.js View on Github external
registerReactions() {
        // Switch account reactions.
        when(
            () => this.switched,
            this.switchAccountHandler
        );
    }
github wp-pwa / wp-pwa / core / packages / analytics / pwa / sagas / comScore.js View on Github external
export function virtualPageView({ selectedItem }, comScoreIds, titleMatches) {
  // Executes disposer if there is a pending pageview.
  if (typeof disposer === 'function') {
    disposer();
    disposer = null;
  }

  // Gets single from selected item.
  const { title } = selectedItem.entity.headMeta;

  // Waits for the correct url and title and then sends beacons.
  disposer = when(
    () => selectedItem.entity.isReady,
    async () => {
      await titleMatches(title);
      if (window.COMSCORE) comScoreIds.forEach(id => window.COMSCORE.beacon({ c1: '2', c2: id }));
    },
  );
}
github Emurgo / yoroi-frontend / app / stores / toplevel / LoadingStore.js View on Github external
setup() {
    when(this._isRefresh, this._redirectToLoading);
    Promise.all([loadRustModule(), loadLovefieldDB()])
      .then(async () => {
        await this._openPageAfterLoad();
        runInAction(() => {
          this.error = null;
          this._loading = false;
        });
        return undefined;
      })
      .catch((error) => {
        console.error('LoadingStore::setup Unable to load libraries', error);
        runInAction(() => {
          this.error = localizedError(new UnableToLoadError());
          this._loading = false;
        });
      });
github birkir / hekla / src / screens / account / Account.tsx View on Github external
componentDidMount() {
    when(
      () => Account.user && Account.user.id !== null,
      this.updateOptions,
    );
  }
github knoopx / plex-music / src / renderer / store / index.js View on Github external
afterCreate() {
        disposables.push(
          when(
            () => self.account.isLoggedIn && !self.activeDevice,
            () => {
              if (self.account.devices.length === 1) {
                self.setActiveDevice(self.account.devices[0])
              }
            },
          ),
        )

        disposables.push(
          autorun(() => {
            if (self.activeDevice) {
              self.activeDevice.fetchSections()
            }
          }),
        )
github owid / owid-grapher / admin / client / DatasetEditPage.tsx View on Github external
componentDidMount() {
        this.chart = new ChartConfig(this.chartConfig as any, { isEmbed: true })

        this.dispose2 = when(
            () => this.chart !== undefined && this.chart.data.isReady,
            () => this.chartIsReady(this.chart as ChartConfig)
        )

        this.dispose = autorun(() => {
            const chart = this.chart
            const display = _.clone(this.newVariable.display)
            if (chart) {
                runInAction(() => (chart.props.dimensions[0].display = display))
            }
        })
    }
github electron / fiddle / src / renderer / remote-loader.ts View on Github external
public async verifyReleaseChannelEnabled(channel: string): Promise {
    this.appState.setWarningDialogTexts({
      label: `You're loading an example with a version of Electron with an unincluded release
              channel (${channel}). Do you want to enable the release channel to load the
              version of Electron from the example?`
    });
    this.appState.isWarningDialogShowing = true;
    await when(() => !this.appState.isWarningDialogShowing);

    return !!this.appState.warningDialogLastResult;
  }