deep-storage
Advanced tools
Comparing version 0.3.3 to 0.3.4
@@ -22,2 +22,3 @@ import { DeepStorage, UsesDeepStorage } from "./index"; | ||
rerun(): Promise<DeepAsyncData<Request, Response>>; | ||
update(response: Response): Promise<DeepAsyncData<Request, Response>>; | ||
} | ||
@@ -31,3 +32,4 @@ export declare class AlreadyRunningError extends Error { | ||
run: (request: Request) => Promise<DeepAsyncData<Request, Response>>; | ||
rerun(): Promise<DeepAsyncData<Request, Response>>; | ||
rerun: () => Promise<DeepAsyncData<Request, Response>>; | ||
update: (response: Response) => Promise<DeepAsyncData<Request, Response>>; | ||
readonly status: AsyncStatus; | ||
@@ -34,0 +36,0 @@ readonly running: boolean; |
@@ -107,6 +107,16 @@ "use strict"; | ||
}); }; | ||
this.rerun = function () { | ||
return _this.run(_this.request); | ||
}; | ||
this.update = function (response) { return __awaiter(_this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.storage.update(function (state) { return (__assign({}, state, { status: AsyncStatus.Succeeded, response: response, error: undefined })); })]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/, this.storage.state]; | ||
} | ||
}); | ||
}); }; | ||
} | ||
DefaultDeepAsync.prototype.rerun = function () { | ||
return this.run(this.request); | ||
}; | ||
Object.defineProperty(DefaultDeepAsync.prototype, "status", { | ||
@@ -113,0 +123,0 @@ get: function () { return this.storage.state.status; }, |
{ | ||
"name": "deep-storage", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"description": "Simple observable state management for reactive applications", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -27,2 +27,3 @@ import { DeepStorage, UsesDeepStorage } from "./index"; | ||
rerun(): Promise<DeepAsyncData<Request, Response>>; | ||
update(response: Response): Promise<DeepAsyncData<Request, Response>>; | ||
} | ||
@@ -52,5 +53,9 @@ | ||
} | ||
rerun(): Promise<DeepAsyncData<Request, Response>> { | ||
rerun = (): Promise<DeepAsyncData<Request, Response>> => { | ||
return this.run(this.request); | ||
} | ||
update = async (response: Response): Promise<DeepAsyncData<Request, Response>> => { | ||
await this.storage.update(state => ({ ...state, status: AsyncStatus.Succeeded, response, error: undefined })); | ||
return this.storage.state; | ||
} | ||
get status() { return this.storage.state.status; } | ||
@@ -57,0 +62,0 @@ get running() { return this.storage.state.status === AsyncStatus.Running } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
181269
1055