aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/lib
diff options
context:
space:
mode:
authorLibravatar Ricardo Cino <ricardo@cino.io>2022-07-07 09:31:50 +0200
committerLibravatar GitHub <noreply@github.com>2022-07-07 09:31:50 +0200
commit71c52373f81cace664047edd19d9d289f45a4dff (patch)
tree69b3f1d45a8b3f1ceab9497ea3c96e9dc18e3166 /src/stores/lib
parent6.0.0-nightly.91 [skip ci] (diff)
downloadferdium-app-71c52373f81cace664047edd19d9d289f45a4dff.tar.gz
ferdium-app-71c52373f81cace664047edd19d9d289f45a4dff.tar.zst
ferdium-app-71c52373f81cace664047edd19d9d289f45a4dff.zip
chore: Mobx & React-Router upgrade (#406)
Co-authored-by: Vijay A <vraravam@users.noreply.github.com>
Diffstat (limited to 'src/stores/lib')
-rw-r--r--src/stores/lib/Request.js4
-rw-r--r--src/stores/lib/TypedStore.ts20
2 files changed, 17 insertions, 7 deletions
diff --git a/src/stores/lib/Request.js b/src/stores/lib/Request.js
index 0ac36a218..e58341790 100644
--- a/src/stores/lib/Request.js
+++ b/src/stores/lib/Request.js
@@ -1,4 +1,4 @@
1import { observable, action, computed } from 'mobx'; 1import { observable, action, computed, makeObservable } from 'mobx';
2import { isEqual } from 'lodash/fp'; 2import { isEqual } from 'lodash/fp';
3 3
4export default class Request { 4export default class Request {
@@ -29,6 +29,8 @@ export default class Request {
29 _currentApiCall = null; 29 _currentApiCall = null;
30 30
31 constructor(api, method) { 31 constructor(api, method) {
32 makeObservable(this);
33
32 this._api = api; 34 this._api = api;
33 this._method = method; 35 this._method = method;
34 } 36 }
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 @@
1import { computed, IReactionPublic, observable } from 'mobx'; 1import { computed, IReactionPublic, makeObservable, observable } from 'mobx';
2import { Actions } from '../../actions/lib/actions'; 2import { Actions } from '../../actions/lib/actions';
3import { ApiInterface } from '../../api'; 3import { ApiInterface } from '../../api';
4import { Stores } from '../../@types/stores.types'; 4import { 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) {