4
0
forked from crowetic/commerce

Export the extend fn

This commit is contained in:
Luis Alvarez 2020-10-09 13:24:13 -05:00
parent 22ba0d7315
commit d67c728e80
4 changed files with 12 additions and 12 deletions

View File

@ -19,7 +19,7 @@ export const fetcher: HookFetcher<Cart | null, HookDeps[]> = (
})
}
function extend(customFetcher: typeof fetcher) {
export function extendHook(customFetcher: typeof fetcher) {
const useCart = () => {
const cart = useCommerceCart<Cart | null>(
[defaultOpts.url, undefined],
@ -40,9 +40,9 @@ function extend(customFetcher: typeof fetcher) {
return cart
}
useCart.extend = extend
useCart.extend = extendHook
return useCart
}
export const useCart = extend(fetcher)
export const useCart = extendHook(fetcher)

View File

@ -32,7 +32,7 @@ export const fetcher: HookFetcher<Cart, AddItemBody> = (
})
}
function extend(customFetcher: typeof fetcher) {
export function extendHook(customFetcher: typeof fetcher) {
const useAddItem = () => {
const { mutate } = useCart()
const fn = useCartAddItem<Cart, AddItemBody>(defaultOpts, customFetcher)
@ -47,9 +47,9 @@ function extend(customFetcher: typeof fetcher) {
)
}
useAddItem.extend = extend
useAddItem.extend = extendHook
return useAddItem
}
export default extend(fetcher)
export default extendHook(fetcher)

View File

@ -25,7 +25,7 @@ export const fetcher: HookFetcher<Cart | null, RemoveItemBody> = (
})
}
function extend(customFetcher: typeof fetcher) {
export function extendHook(customFetcher: typeof fetcher) {
const useRemoveItem = (item?: any) => {
const { mutate } = useCart()
const fn = useCartRemoveItem<Cart | null, RemoveItemBody>(
@ -43,9 +43,9 @@ function extend(customFetcher: typeof fetcher) {
)
}
useRemoveItem.extend = extend
useRemoveItem.extend = extendHook
return useRemoveItem
}
export default extend(fetcher)
export default extendHook(fetcher)

View File

@ -34,7 +34,7 @@ export const fetcher: HookFetcher<Cart | null, UpdateItemBody> = (
})
}
function extend(customFetcher: typeof fetcher, cfg?: { wait?: number }) {
function extendHook(customFetcher: typeof fetcher, cfg?: { wait?: number }) {
const useUpdateItem = (item?: any) => {
const { mutate } = useCart()
const fn = useCartUpdateItem<Cart | null, UpdateItemBody>(
@ -59,9 +59,9 @@ function extend(customFetcher: typeof fetcher, cfg?: { wait?: number }) {
)
}
useUpdateItem.extend = extend
useUpdateItem.extend = extendHook
return useUpdateItem
}
export default extend(fetcher)
export default extendHook(fetcher)