diff options
author | 2022-07-07 09:31:50 +0200 | |
---|---|---|
committer | 2022-07-07 09:31:50 +0200 | |
commit | 71c52373f81cace664047edd19d9d289f45a4dff (patch) | |
tree | 69b3f1d45a8b3f1ceab9497ea3c96e9dc18e3166 /src/stores/lib/TypedStore.ts | |
parent | 6.0.0-nightly.91 [skip ci] (diff) | |
download | ferdium-app-71c5237.tar.gz ferdium-app-71c5237.tar.zst ferdium-app-71c5237.zip |
chore: Mobx & React-Router upgrade (#406)
Co-authored-by: Vijay A <vraravam@users.noreply.github.com>
Diffstat (limited to 'src/stores/lib/TypedStore.ts')
-rw-r--r-- | src/stores/lib/TypedStore.ts | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/stores/lib/TypedStore.ts b/src/stores/lib/TypedStore.ts index c97ae1aa5..e44eadd32 100644 --- a/src/stores/lib/TypedStore.ts +++ b/src/stores/lib/TypedStore.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { computed, IReactionPublic, observable } from 'mobx'; | 1 | import { computed, IReactionPublic, makeObservable, observable } from 'mobx'; |
2 | import { Actions } from '../../actions/lib/actions'; | 2 | import { Actions } from '../../actions/lib/actions'; |
3 | import { ApiInterface } from '../../api'; | 3 | import { ApiInterface } from '../../api'; |
4 | import { Stores } from '../../@types/stores.types'; | 4 | import { Stores } from '../../@types/stores.types'; |
@@ -9,6 +9,12 @@ export default abstract class TypedStore { | |||
9 | 9 | ||
10 | @observable _status: any = null; | 10 | @observable _status: any = null; |
11 | 11 | ||
12 | stores: Stores; | ||
13 | |||
14 | api: ApiInterface; | ||
15 | |||
16 | actions: Actions; | ||
17 | |||
12 | @computed get actionStatus() { | 18 | @computed get actionStatus() { |
13 | return this._status || []; | 19 | return this._status || []; |
14 | } | 20 | } |
@@ -17,11 +23,13 @@ export default abstract class TypedStore { | |||
17 | this._status = status; | 23 | this._status = status; |
18 | } | 24 | } |
19 | 25 | ||
20 | constructor( | 26 | constructor(stores: Stores, api: ApiInterface, actions: Actions) { |
21 | public readonly stores: Stores, | 27 | makeObservable(this); |
22 | public readonly api: ApiInterface, | 28 | |
23 | public readonly actions: Actions, | 29 | this.stores = stores; |
24 | ) {} | 30 | this.api = api; |
31 | this.actions = actions; | ||
32 | } | ||
25 | 33 | ||
26 | registerReactions(reactions: { (r: IReactionPublic): void }[]): void { | 34 | registerReactions(reactions: { (r: IReactionPublic): void }[]): void { |
27 | for (const reaction of reactions) { | 35 | for (const reaction of reactions) { |