Created
February 17, 2022 22:05
-
-
Save whisher/a04adea9cc2c8fb3b7c3c2ca24c1cc3c to your computer and use it in GitHub Desktop.
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
export interface DataState { | |
error: string | null; | |
loaded: boolean; | |
data: GetIssuesQuery | undefined; | |
} | |
const initialState: DataState = { | |
error: null, | |
loaded: false, | |
data: undefined | |
}; | |
const store = writable<DataState>(initialState); | |
const dataStore = { | |
subscribe: store.subscribe, | |
success: (data: GetIssuesQuery) => { | |
store.update((state) => { | |
return { | |
...state, | |
loaded: true, | |
data | |
}; | |
}); | |
}, | |
failure: (error:string) => { | |
store.update(() => { | |
return { | |
error, | |
loaded: false, | |
data: undefined | |
}; | |
}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment