mirror of
https://github.com/sergeyyarkov/educt-client.git
synced 2026-10-11 10:19:22 +03:00
refactor: ui store events
This commit is contained in:
parent
91fed1a002
commit
e741c2b913
@ -1,10 +1,18 @@
|
||||
import { makeAutoObservable } from 'mobx';
|
||||
import Cookies from 'js-cookie';
|
||||
import RootStore from './RootStore';
|
||||
import AuthService from 'services/AuthService';
|
||||
import { AxiosInstance } from 'axios';
|
||||
import { IDataResult, ILoginResult } from 'interfaces';
|
||||
|
||||
/**
|
||||
* Services
|
||||
*/
|
||||
import AuthService from 'services/AuthService';
|
||||
|
||||
/**
|
||||
* Stores
|
||||
*/
|
||||
import RootStore from './RootStore';
|
||||
|
||||
export default class AuthStore {
|
||||
public root: RootStore;
|
||||
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
import { makeAutoObservable, observable } from 'mobx';
|
||||
import { createBrowserHistory } from 'history';
|
||||
import RootStore from './RootStore';
|
||||
import { IWindowDimensions } from 'interfaces';
|
||||
|
||||
/**
|
||||
* Stores
|
||||
*/
|
||||
import RootStore from './RootStore';
|
||||
|
||||
export default class UIStore {
|
||||
public root: RootStore;
|
||||
|
||||
@ -20,22 +24,33 @@ export default class UIStore {
|
||||
windowDimensions: observable.struct,
|
||||
});
|
||||
|
||||
this.setupListeners();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize some listeners
|
||||
*/
|
||||
private setupListeners(): void {
|
||||
/**
|
||||
* Pathname changed
|
||||
*/
|
||||
this.history.listen(({ pathname }) => {
|
||||
console.log(`[history]: pathname changed to "${pathname}"`);
|
||||
this.location = pathname;
|
||||
});
|
||||
|
||||
window.onresize = () => {
|
||||
this.windowDimensions = this.getWindowDimensions();
|
||||
};
|
||||
/**
|
||||
* Window dimensions updated
|
||||
*/
|
||||
window.onresize = () => this.updateWindowDimensions();
|
||||
}
|
||||
|
||||
public setLocation(location: string): void {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
private getWindowDimensions(): IWindowDimensions {
|
||||
return { width: window.innerWidth, height: window.innerHeight };
|
||||
private updateWindowDimensions(): void {
|
||||
this.windowDimensions = { width: window.innerWidth, height: window.innerHeight };
|
||||
}
|
||||
|
||||
get isDesktop() {
|
||||
|
||||
@ -2,7 +2,14 @@ import { AxiosInstance } from 'axios';
|
||||
import { makeAutoObservable, runInAction } from 'mobx';
|
||||
import { IUserResult, IUser } from 'interfaces';
|
||||
|
||||
/**
|
||||
* Services
|
||||
*/
|
||||
import UserService from 'services/UserService';
|
||||
|
||||
/**
|
||||
* Stores
|
||||
*/
|
||||
import RootStore from './RootStore';
|
||||
|
||||
export default class UserStore {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user