How to use the mobx-utils.fromPromise function in mobx-utils

To help you get started, we’ve selected a few mobx-utils 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 jenkinsci / blueocean-plugin / blueocean-core-js / src / js / services / ActivityService.js View on Github external
fetchArtifacts(runHref) {
        return mobxUtils.fromPromise(Fetch.fetchJSON(`${runHref}artifacts/?start=0&limit=101`));
    }
github ExpediaDotCom / haystack-ui / src / components / alerts / stores / alertDetailsStore.js View on Github external
@action deleteSubscription(subscriptionId) {
        this.subscriptionsPromiseState = fromPromise(
            axios
                .delete(`/api/alert/subscriptions/${subscriptionId}`)
                .then(() => {
                    _.remove(this.alertSubscriptions, subscription => subscription.subscriptionId === subscriptionId);
                })
                .catch((result) => {
                    AlertDetailsStore.handleError(result);
                })
        );
    }
}
github ExpediaDotCom / haystack-ui / src / components / traces / stores / traceDetailsStore.js View on Github external
fetchTraceResults(queryUrlString) {
        this.relatedTracesPromiseState = fromPromise(
            axios
            .get(`/api/traces?${queryUrlString}`)
            .then((result) => {
                this.relatedTraces = formatResults(result.data);
            })
            .catch((result) => {
                this.relatedTraces = [];
                TraceDetailsStore.handleError(result);
            })
        );
    }
github ExpediaDotCom / haystack-ui / src / components / traces / stores / rawSpanStore.js View on Github external
@action fetchRawSpan(traceId, spanId, serviceName) {
        this.promiseState = fromPromise(
            axios
                .get(`/api/trace/raw/${traceId}/${spanId}?serviceName=${serviceName}`)
                .then((result) => {
                    this.rawSpan = result.data;
                })
                .catch((result) => {
                    RawSpanStore.handleError(result);
                })
        );
    }
}
github ExpediaDotCom / haystack-ui / src / components / trends / stores / serviceStore.js View on Github external
@action fetchTrends(service, type, query) {
        const queryUrlString = toQueryUrlString(query);
        this.trendsPromiseState = fromPromise(
            axios
                .get(`/api/trends/service/${service}/${type}?${queryUrlString}`)
                .then((result) => {
                    this.trendsResults = result.data;
                    this.trendsQuery = query;
                })
                .catch((result) => {
                    this.trendsQuery = query;
                    this.trendsResults = [];
                    ServiceStore.handleError(result);
                })
        );
    }
}
github ExpediaDotCom / haystack-ui / src / components / alerts / stores / alertDetailsStore.js View on Github external
@action updateSubscription(subscriptionId, dispatcherId, errorCallback) {
        this.subscriptionsPromiseState = fromPromise(
            axios
                .put(`/api/alert/subscriptions/${subscriptionId}`, {dispatcherId})
                .then(() => {
                    const original = this.alertSubscriptions.find(subscription => subscription.subscriptionId === subscriptionId);
                    original.dispatcherIds[0] = dispatcherId;
                })
                .catch((result) => {
                    errorCallback();
                    AlertDetailsStore.handleError(result);
                })
        );
    }
github TerriaJS / terriajs / lib / Models / SearchProviderResults.ts View on Github external
import { observable } from "mobx";
import SearchResult from "./SearchResult";
import { IPromiseBasedObservable, fromPromise } from "mobx-utils";
import SearchProvider from "./SearchProvider";

export default class SearchProviderResults {
  @observable results: SearchResult[] = [];
  @observable message: string | undefined;
  isCanceled = false;
  resultsCompletePromise: IPromiseBasedObservable = fromPromise(
    Promise.resolve()
  );

  constructor(readonly searchProvider: SearchProvider) {}

  get isSearching() {
    return this.resultsCompletePromise.state === "pending";
  }
}
github PacktPublishing / MobX-Quick-Start-Guide / src / Chapter08 / fromPromise.js View on Github external
start() {
        this.operation = fromPromise(this.performOperation());
    }
github ExpediaDotCom / haystack-ui / src / components / traces / stores / spansSearchStore.js View on Github external
@action fetchSpans(traceIds) {
        this.promiseState = fromPromise(
            axios
                .get(`/api/traces/raw?traceIds=${encodeURIComponent(JSON.stringify(traceIds))}`)
                .then((result) => {
                    this.results = result.data;
                })
                .catch((result) => {
                    SpansSearchStore.handleError(result);
                })
        );
    }
}
github ExpediaDotCom / haystack-ui / src / components / alerts / stores / alertDetailsStore.js View on Github external
@action fetchAlertSubscriptions(serviceName, operationName, type) {
        this.subscriptionsPromiseState = fromPromise(
            axios
                .get(`/api/alert/${serviceName}/${operationName}/${type}/subscriptions`)
                .then((result) => {
                    this.alertSubscriptions = result.data;
                })
                .catch((result) => {
                    AlertDetailsStore.handleError(result);
                })
        );
    }