Created
September 14, 2021 11:27
-
-
Save ahartzog/e59491b096a1f388d97ba7bd4f00cb0d to your computer and use it in GitHub Desktop.
File uploading store example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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