migrated from redux to recoil
This commit is contained in:
39
frontend/src/atoms/status.ts
Normal file
39
frontend/src/atoms/status.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { atom, selector } from 'recoil'
|
||||
|
||||
type StatusState = {
|
||||
connected: boolean,
|
||||
updated: boolean,
|
||||
downloading: boolean,
|
||||
freeSpace: number,
|
||||
}
|
||||
|
||||
|
||||
export const connectedState = atom({
|
||||
key: 'connectedState',
|
||||
default: false
|
||||
})
|
||||
|
||||
export const updatedBinaryState = atom({
|
||||
key: 'updatedBinaryState',
|
||||
default: false
|
||||
})
|
||||
|
||||
export const isDownloadingState = atom({
|
||||
key: 'isDownloadingState',
|
||||
default: false
|
||||
})
|
||||
|
||||
export const freeSpaceBytesState = atom({
|
||||
key: 'freeSpaceBytesState',
|
||||
default: 0
|
||||
})
|
||||
|
||||
export const statusState = selector<StatusState>({
|
||||
key: 'statusState',
|
||||
get: ({ get }) => ({
|
||||
connected: get(connectedState),
|
||||
updated: get(updatedBinaryState),
|
||||
downloading: get(isDownloadingState),
|
||||
freeSpace: get(freeSpaceBytesState),
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user