How to use the redux-query/dist/commonjs/lib/query-key.reconcileQueryKey function in redux-query

To help you get started, we’ve selected a few redux-query 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 isaacplmann / ngrx-query / lib / services / effects.service.js View on Github external
.mergeMap(function (action) {
            var url = action.url, _a = action.transform, transform = _a === void 0 ? identity : _a, update = action.update, body = action.body, optimisticUpdate = action.optimisticUpdate, _b = action.options, options = _b === void 0 ? {} : _b;
            invariant(!!url, 'Missing required `url` field in action handler');
            var state = getLatest(_this.store);
            var entities = _this.config && _this.config.entitiesSelector && _this.config.entitiesSelector(state)
                || defaultEntitiesSelector(state);
            var optimisticEntities;
            if (optimisticUpdate) {
                optimisticEntities = optimisticUpdateEntities(optimisticUpdate, entities);
            }
            var queryKey = reconcileQueryKey(action);
            // const start = new Date();
            var _c = options.method, method = _c === void 0 ? httpMethods.POST : _c;
            var request = {
                url: url,
                method: method,
                body: body,
                headers: options.headers,
                withCredentials: options.credentials === 'include',
            };
            // Note: only the entities that are included in `optimisticUpdate` will be passed along in the
            // `mutateStart` action as `optimisticEntities`
            _this.store.dispatch(actions.mutateStart(url, body, request, optimisticEntities, queryKey));
            return _this.http.request(url, request)
                .map(function (response) {
                if (!response.ok) {
                    throw response;
github isaacplmann / ngrx-query / lib / services / effects.service.js View on Github external
.map(function (action) {
            var url = action.url, force = action.force, retry = action.retry, update = action.update;
            invariant(!!url, 'Missing required `url` field in action handler');
            invariant(!!update, 'Missing required `update` field in action handler');
            var queryKey = reconcileQueryKey(action);
            var state = getLatest(_this.store);
            var queries = _this.config && _this.config.queriesSelector && _this.config.queriesSelector(state)
                || defaultQueriesSelector(state);
            var queriesState = queries[queryKey];
            var _a = queriesState || {}, isPending = _a.isPending, status = _a.status;
            var hasSucceeded = status >= 200 && status < 300;
            var attemptRequest = force || !queriesState || (retry !== false && !isPending && !hasSucceeded);
            return { attemptRequest: attemptRequest, action: action };
        })
            .filter(function (_a) {
github isaacplmann / ngrx-query / lib / services / effects.service.js View on Github external
.mergeMap(function (_a) {
            var action = _a.action;
            var url = action.url, body = action.body, _b = action.transform, transform = _b === void 0 ? identity : _b, update = action.update, _c = action.options, options = _c === void 0 ? {} : _c, meta = action.meta;
            var queryKey = reconcileQueryKey(action);
            var start = new Date();
            var _d = options.method, method = _d === void 0 ? httpMethods.GET : _d;
            var request = {
                url: url,
                method: method,
                body: body,
                headers: options.headers,
                withCredentials: options.credentials === 'include',
            };
            return Observable.of({})
                .mergeMap(function () {
                _this.store.dispatch(actions.requestStart(url, body, request, meta, queryKey));
                return _this.http.request(url, request)
                    .map(function (response) {
                    if (!response.ok) {
                        throw response;