forked from ddrilling/asb_cloud_front
Add sync method invokeWebApiWrapper
This commit is contained in:
parent
178057049f
commit
3f4464b068
@ -69,6 +69,22 @@ export const makePaginationObject = (paginationContainer:PaginationContainer, ..
|
||||
}
|
||||
}
|
||||
|
||||
export const invokeWebApiWrapper = async (func: Function, setShowLoader: Dispatch<SetStateAction<boolean>>, errorNotifyText: string) => {
|
||||
if(setShowLoader)
|
||||
setShowLoader(true)
|
||||
try{
|
||||
func()
|
||||
} catch (ex) {
|
||||
if(process.env.NODE_ENV === 'development')
|
||||
console.log(ex)
|
||||
if(errorNotifyText)
|
||||
notify(errorNotifyText, 'error')
|
||||
} finally{
|
||||
if(setShowLoader)
|
||||
setShowLoader(false)
|
||||
}
|
||||
}
|
||||
|
||||
export const invokeWebApiWrapperAsync = async (funcAsync: asyncFunction, setShowLoader: Dispatch<SetStateAction<boolean>>, errorNotifyText: string) => {
|
||||
if(setShowLoader)
|
||||
setShowLoader(true)
|
||||
|
Loading…
Reference in New Issue
Block a user