Properties
Optional Readonly annotated
busy
busy: boolean = false
entries
entries: Map<T["model"]["key"], T["model"]> = new Map<T["model"]["key"], T["model"]>()
get
get: (data?: { clear?: boolean; params?: T["getParameters"]; request?: T["getParameters"] }) => CancellablePromise<void> = flow(function* (this: ClientCollection<any>, data) {const { request, params, clear = false } = data || {};this.busy = true;try {const { path, namespace } = this.annotated;const response: T["response"] = yield this.annotated.request<T["getParameters"],T["getParameters"],T["response"]>({location: {path,method: ERouteHttpVerb.GET,namespace},request,params});// Save cookies as modelsclear && this.entries.clear();for (const row of response) {const instance = this.instance(row) as T["model"];const existing = this.entries.get(instance.key);if (!existing) {this.entries.set(instance.key, instance);} else {// Update stale dataexisting.data = instance.data;}}} catch (e) {console.log(e);throw e;} finally {this.busy = false;}})
Type declaration
-
- (data?: { clear?: boolean; params?: T["getParameters"]; request?: T["getParameters"] }): CancellablePromise<void>
-
Parameters
-
Optional data: { clear?: boolean; params?: T["getParameters"]; request?: T["getParameters"] }
-
Optional clear?: boolean
-
Optional params?: T["getParameters"]
-
Optional request?: T["getParameters"]
Returns CancellablePromise<void>
getSingle
getSingle: (data?: { params?: T["getSingleParameters"]; request?: T["getSingleParameters"] }) => CancellablePromise<void> = flow(function* (this: ClientCollection<any>, data) {if (!this.annotated.singlePath) {throw new Error("There is no getSingle method allowed");}const { request, params } = data || {};this.busy = true;try {const { singlePath, namespace } = this.annotated;const row: T["response"] = yield this.annotated.request<T["getSingleParameters"],T["getSingleParameters"],T["response"]>({location: {path: singlePath,method: ERouteHttpVerb.GET,namespace},request,params});// Save cookie as modelconst instance = this.instance(row) as T["model"];this.entries.set(instance.key, instance);} catch (e) {console.log(e);throw e;} finally {this.busy = false;}})
Type declaration
-
- (data?: { params?: T["getSingleParameters"]; request?: T["getSingleParameters"] }): CancellablePromise<void>
-
Parameters
-
Optional data: { params?: T["getSingleParameters"]; request?: T["getSingleParameters"] }
-
Optional params?: T["getSingleParameters"]
-
Optional request?: T["getSingleParameters"]
Returns CancellablePromise<void>