@hulanbv/nest-utilities-client-state
Advanced tools
Comparing version 0.3.4 to 0.4.0
@@ -27,3 +27,3 @@ "use strict"; | ||
const { immediateFetch = true } = stateOptions; | ||
const _httpOptions = Object.assign(Object.assign({}, httpOptions), { filter: Object.assign(Object.assign({}, httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.filter), { _id: { $in: ids } }) }); | ||
const _httpOptions = Object.assign(Object.assign({}, httpOptions), { match: Object.assign(Object.assign({}, httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.match), { _id: { $in: ids } }) }); | ||
const _a = useRequest_1.useRequest(service, '', 'GET', _httpOptions, stateOptions), { data, response, call } = _a, rest = __rest(_a, ["data", "response", "call"]); | ||
@@ -30,0 +30,0 @@ const stringifiedHttpOptions = stringifyHttpOptions_1.stringifyHttpOptions(_httpOptions); |
@@ -30,6 +30,12 @@ import { CrudService, IResponse } from 'nest-utilities-client'; | ||
export interface IStateOptions { | ||
/** Cache with generated or speficic key */ | ||
cache?: boolean | string; | ||
/** Fetch immediately on hook creation */ | ||
immediateFetch?: boolean; | ||
/** Proxy method */ | ||
proxyMethod?: FetchMethod; | ||
/** Log request state info */ | ||
debug?: boolean; | ||
/** Request payload body property to append the given query to */ | ||
appendQuery?: string; | ||
} | ||
@@ -36,0 +42,0 @@ declare type SimplePromise = Promise<boolean>; |
@@ -23,2 +23,4 @@ import { CrudService, IHttpOptions, IResponse } from 'nest-utilities-client'; | ||
private cache; | ||
/** Request payload body property to append the given query to */ | ||
private appendQuery?; | ||
private static cacheKeyNamePrefix; | ||
@@ -41,3 +43,5 @@ cacheKey?: string; | ||
* */ | ||
cache?: boolean | string); | ||
cache?: boolean | string, | ||
/** Request payload body property to append the given query to */ | ||
appendQuery?: string | undefined); | ||
get data(): ResponseData<Model>; | ||
@@ -44,0 +48,0 @@ get fetchState(): FetchState; |
@@ -49,3 +49,5 @@ "use strict"; | ||
* */ | ||
cache = false) { | ||
cache = false, | ||
/** Request payload body property to append the given query to */ | ||
appendQuery) { | ||
var _a; | ||
@@ -58,2 +60,3 @@ this.service = service; | ||
this.cache = cache; | ||
this.appendQuery = appendQuery; | ||
_changeHandlers.set(this, []); | ||
@@ -98,2 +101,9 @@ _fetchState.set(this, types_1.FetchState.Idle); | ||
else { | ||
// Append query to body | ||
if (this.appendQuery) { | ||
if (body instanceof FormData) | ||
body.set(this.appendQuery, this.query); | ||
if (body) | ||
body[this.appendQuery] = this.query; | ||
} | ||
// Handle every fetch method... | ||
@@ -100,0 +110,0 @@ if (method === 'GET') { |
{ | ||
"name": "@hulanbv/nest-utilities-client-state", | ||
"version": "0.3.4", | ||
"version": "0.4.0", | ||
"description": "React hooks for state management when using nest-utilities-client and a nest-utilities based API.", | ||
@@ -30,3 +30,3 @@ "main": "dist/index.js", | ||
"peerDependencies": { | ||
"nest-utilities-client": "^3.0.0", | ||
"nest-utilities-client": "^3.1.0", | ||
"react": "^16.8.0" | ||
@@ -45,3 +45,3 @@ }, | ||
"lint-staged": "^10.5.3", | ||
"nest-utilities-client": "^3.0.0", | ||
"nest-utilities-client": "^3.1.0", | ||
"prettier": "^2.2.1", | ||
@@ -48,0 +48,0 @@ "react": "^16.8.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
76348
962