You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
610 B

import { ISprinklersDevice, IUser } from "@common/httpApi";
import { action, IObservableValue, observable } from "mobx";
export class UserStore {
userData: IObservableValue<IUser | null> = observable.box(null);
@action.bound
receiveUserData(userData: IUser) {
this.userData.set(userData);
}
getUserData(): IUser | null {
return this.userData.get();
}
findDevice(id: number): ISprinklersDevice | null {
const userData = this.userData.get();
return (
(userData &&
userData.devices &&
userData.devices.find(dev => dev.id === id)) ||
null
);
}
}