Skip to content

Instantly share code, notes, and snippets.

@ahartzog
Created September 14, 2021 11:27
Show Gist options
  • Save ahartzog/e59491b096a1f388d97ba7bd4f00cb0d to your computer and use it in GitHub Desktop.
Save ahartzog/e59491b096a1f388d97ba7bd4f00cb0d to your computer and use it in GitHub Desktop.
File uploading store example
import { observable, action, makeObservable } from 'mobx';
class FilesUIStore {
constructor() {
makeObservable(this, {
isUploading: observable,
uploadLoadProgress: observable,
isCompressing: observable,
dontShowProgress: observable,
setIsUploading: action,
setDontShowProgress: action,
setUploadProgress: action,
setCompressing: action,
});
}
isUploading = false;
uploadLoadProgress = 0;
isCompressing = false;
dontShowProgress = true;
setIsUploading = (set: boolean) => {
this.isUploading = set;
};
setDontShowProgress = (set: boolean) => {
this.dontShowProgress = set;
};
setUploadProgress = (set: number) => {
this.uploadLoadProgress = set;
};
setCompressing = (set: boolean) => {
this.isCompressing = set;
};
}
const singleton = new FilesUIStore();
export default singleton;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment