diff --git a/src/components/factory.ts b/src/components/factory.ts index dca00cf..3dd5ec6 100644 --- a/src/components/factory.ts +++ b/src/components/factory.ts @@ -69,6 +69,22 @@ export const makePaginationObject = (paginationContainer:PaginationContainer, .. } } +export const invokeWebApiWrapper = async (func: Function, setShowLoader: Dispatch>, 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>, errorNotifyText: string) => { if(setShowLoader) setShowLoader(true)