mobx#makeAutoObservable TypeScript Examples

The following examples show how to use mobx#makeAutoObservable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: interaction.ts    From hubble-ui with Apache License 2.0 6 votes vote down vote up
constructor() {
    this._flows = [];
    this._links = [];
    this.l7endpoints = new GroupedPartialConnections();

    makeAutoObservable(this, void 0, {
      autoBind: true,
    });
  }
Example #2
Source File: ApplicationStore.ts    From legend-studio with Apache License 2.0 6 votes vote down vote up
constructor(
    config: T,
    navigator: WebApplicationNavigator,
    pluginManager: LegendApplicationPluginManager,
  ) {
    makeAutoObservable(this, {
      navigator: false,
      setBlockingAlert: action,
      setActionAlertInfo: action,
      setNotification: action,
      notify: action,
      notifySuccess: action,
      notifyWarning: action,
      notifyIllegalState: action,
      notifyError: action,
    });

    this.config = config;
    this.navigator = navigator;
    this.pluginManager = pluginManager;
    this.navigationContextService =
      new LegendApplicationNavigationContextService();
    this.documentationService = new LegendApplicationDocumentationService(this);
    this.assistantService = new LegendApplicationAssistantService(this);
    this.log.registerPlugins(pluginManager.getLoggerPlugins());
    this.telemetryService.registerPlugins(
      pluginManager.getTelemetryServicePlugins(),
    );
    this.tracerService.registerPlugins(pluginManager.getTracerServicePlugins());
    this.eventService.registerEventNotifierPlugins(
      pluginManager.getEventNotifierPlugins(),
    );
  }
Example #3
Source File: batch.ts    From lightning-terminal with MIT License 6 votes vote down vote up
constructor(llmMatch: Required<AUCT.MatchedOrderSnapshot.AsObject>) {
    makeAutoObservable(this, {}, { deep: false, autoBind: true });

    this.matchingRate = llmMatch.matchingRate;
    this.unitsMatched = llmMatch.unitsMatched;
    this.totalSatsCleared = Big(llmMatch.totalSatsCleared);
    this.ask = {
      leaseDurationBlocks: llmMatch.ask.leaseDurationBlocks,
      rateFixed: llmMatch.ask.rateFixed,
    };
    this.bid = {
      leaseDurationBlocks: llmMatch.bid.leaseDurationBlocks,
      rateFixed: llmMatch.bid.rateFixed,
    };
  }
Example #4
Source File: local-state.tsx    From nota with MIT License 6 votes vote down vote up
constructor(contents: string) {
    this.contents = contents;
    this.translation = this.tryTranslate();

    makeAutoObservable(this);

    let needsSync = false;
    reaction(
      () => [this.contents],
      () => {
        needsSync = true;
      }
    );

    const SYNC_INTERVAL = 200;
    setInterval(async () => {
      if (needsSync) {
        let translation = this.tryTranslate();
        needsSync = false;
        runInAction(() => {
          this.translation = translation;
        });
      }
    }, SYNC_INTERVAL);
  }
Example #5
Source File: Singleton.ts    From revite with GNU Affero General Public License v3.0 6 votes vote down vote up
constructor(channel: Channel) {
        this.channel = channel;

        makeAutoObservable(this, {
            channel: false,
            currentRenderer: false,
            scrollPosition: false,
            scrollAnchored: false,
        });

        this.receive = this.receive.bind(this);
        this.edit = this.edit.bind(this);
        this.delete = this.delete.bind(this);

        const client = this.channel.client;
        client.addListener("message", this.receive);
        client.addListener("message/update", this.edit);
        client.addListener("message/delete", this.delete);
    }
Example #6
Source File: Members.ts    From revolt.js with MIT License 6 votes vote down vote up
constructor(client: Client, data: MemberI) {
        this.client = client;
        this._id = data._id;

        this.nickname = toNullable(data.nickname);
        this.avatar = toNullable(data.avatar);
        this.roles = toNullable(data.roles);

        makeAutoObservable(this, {
            _id: false,
            client: false,
        });
    }
Example #7
Source File: graph.ts    From nebula-studio with Apache License 2.0 6 votes vote down vote up
constructor(data?) {
    makeAutoObservable(this, {
      nodeHovering: observable.ref,
      nodeDragging: observable.ref,
      linkHovering: observable.ref,
      pointer: observable.ref,
      nowDataMap: false,
      twoGraph: false,
      canvas: false,
      update: action,
    });
  }
Example #8
Source File: demo-mode-panel.tsx    From ya-webadb with MIT License 6 votes vote down vote up
constructor() {
        makeAutoObservable(this);

        reaction(
            () => GlobalState.device,
            async (device) => {
                if (device) {
                    runInAction(() => this.demoMode = new DemoMode(device));
                    const allowed = await this.demoMode!.getAllowed();
                    runInAction(() => this.allowed = allowed);
                    if (allowed) {
                        const enabled = await this.demoMode!.getEnabled();
                        runInAction(() => this.enabled = enabled);
                    }
                } else {
                    this.demoMode = undefined;
                    this.allowed = false;
                    this.enabled = false;
                    this.features.clear();
                }
            },
            { fireImmediately: true }
        );

        // Apply all features when enable
        autorun(() => {
            if (this.enabled) {
                for (const group of FEATURES) {
                    for (const feature of group) {
                        feature.onChange(this.features.get(feature.key) ?? feature.initial);
                    }
                }
            }
        });
    }
Example #9
Source File: user.store.ts    From MyWay-client with MIT License 6 votes vote down vote up
constructor(
    private readonly rootStore: RootStore,
    private readonly authService: AuthService
  ) {
    this.getUserProfile()
      .then((user: UserDto) => {
        this.setUser(user);
      })
      .catch((e: APIErrorResponse) => {
        console.log(e);
      });

    makeAutoObservable(this);
  }
Example #10
Source File: AppState.ts    From Cromwell with MIT License 5 votes vote down vote up
constructor() {
        makeAutoObservable(this)
    }
Example #11
Source File: usePostState.ts    From bouncecode-cms with GNU General Public License v3.0 5 votes vote down vote up
constructor({id}) {
    this.id = id;
    makeAutoObservable(this);
  }
Example #12
Source File: controls.ts    From hubble-ui with Apache License 2.0 5 votes vote down vote up
constructor() {
    makeAutoObservable(this, void 0, {
      autoBind: true,
    });
  }
Example #13
Source File: NonBlockingDialog.tsx    From legend-studio with Apache License 2.0 5 votes vote down vote up
constructor() {
    makeAutoObservable(this, {
      open: action,
      close: action,
      suppressClickawayEventListener: action,
      handleClickaway: action,
    });
  }
Example #14
Source File: global.store.ts    From react-resume-site with GNU General Public License v3.0 5 votes vote down vote up
constructor() {
		makeAutoObservable(this);
	}
Example #15
Source File: AlertStore.ts    From flood with GNU General Public License v3.0 5 votes vote down vote up
constructor() {
    makeAutoObservable(this);
  }
Example #16
Source File: currentPageHeader.ts    From jitsu with MIT License 5 votes vote down vote up
constructor() {
    makeAutoObservable(this)
  }
Example #17
Source File: game-store.ts    From monopoly with MIT License 5 votes vote down vote up
constructor() {
    makeAutoObservable(this);
  }
Example #18
Source File: account.ts    From lightning-terminal with MIT License 5 votes vote down vote up
constructor(store: Store, poolAccount: POOL.Account.AsObject) {
    makeAutoObservable(this, {}, { deep: false, autoBind: true });

    this._store = store;
    this.update(poolAccount);
  }