diff options
Diffstat (limited to 'src/stores/lib')
-rw-r--r-- | src/stores/lib/Request.js | 24 | ||||
-rw-r--r-- | src/stores/lib/TypedStore.ts | 14 |
2 files changed, 25 insertions, 13 deletions
diff --git a/src/stores/lib/Request.js b/src/stores/lib/Request.js index e58341790..60c943a42 100644 --- a/src/stores/lib/Request.js +++ b/src/stores/lib/Request.js | |||
@@ -18,6 +18,18 @@ export default class Request { | |||
18 | 18 | ||
19 | @observable wasExecuted = false; | 19 | @observable wasExecuted = false; |
20 | 20 | ||
21 | @action _reset() { | ||
22 | this.error = null; | ||
23 | this.result = null; | ||
24 | this.isExecuting = false; | ||
25 | this.isError = false; | ||
26 | this.wasExecuted = false; | ||
27 | this._isWaitingForResponse = false; | ||
28 | this._promise = Promise; | ||
29 | |||
30 | return this; | ||
31 | } | ||
32 | |||
21 | _promise = Promise; | 33 | _promise = Promise; |
22 | 34 | ||
23 | _api = {}; | 35 | _api = {}; |
@@ -139,15 +151,5 @@ export default class Request { | |||
139 | for (const hook of Request._hooks) hook(this); | 151 | for (const hook of Request._hooks) hook(this); |
140 | } | 152 | } |
141 | 153 | ||
142 | reset = () => { | 154 | reset = () => this._reset(); |
143 | this.error = null; | ||
144 | this.result = null; | ||
145 | this.isExecuting = false; | ||
146 | this.isError = false; | ||
147 | this.wasExecuted = false; | ||
148 | this._isWaitingForResponse = false; | ||
149 | this._promise = Promise; | ||
150 | |||
151 | return this; | ||
152 | }; | ||
153 | } | 155 | } |
diff --git a/src/stores/lib/TypedStore.ts b/src/stores/lib/TypedStore.ts index e44eadd32..0a669e669 100644 --- a/src/stores/lib/TypedStore.ts +++ b/src/stores/lib/TypedStore.ts | |||
@@ -1,4 +1,10 @@ | |||
1 | import { computed, IReactionPublic, makeObservable, observable } from 'mobx'; | 1 | import { |
2 | action, | ||
3 | computed, | ||
4 | IReactionPublic, | ||
5 | makeObservable, | ||
6 | observable, | ||
7 | } from 'mobx'; | ||
2 | import { Actions } from '../../actions/lib/actions'; | 8 | import { Actions } from '../../actions/lib/actions'; |
3 | import { ApiInterface } from '../../api'; | 9 | import { ApiInterface } from '../../api'; |
4 | import { Stores } from '../../@types/stores.types'; | 10 | import { Stores } from '../../@types/stores.types'; |
@@ -15,6 +21,10 @@ export default abstract class TypedStore { | |||
15 | 21 | ||
16 | actions: Actions; | 22 | actions: Actions; |
17 | 23 | ||
24 | @action _setResetStatus() { | ||
25 | this._status = null; | ||
26 | } | ||
27 | |||
18 | @computed get actionStatus() { | 28 | @computed get actionStatus() { |
19 | return this._status || []; | 29 | return this._status || []; |
20 | } | 30 | } |
@@ -49,6 +59,6 @@ export default abstract class TypedStore { | |||
49 | } | 59 | } |
50 | 60 | ||
51 | resetStatus(): void { | 61 | resetStatus(): void { |
52 | this._status = null; | 62 | this._setResetStatus(); |
53 | } | 63 | } |
54 | } | 64 | } |