Comparing version 2.1.1 to 2.1.2
{ | ||
"name": "swr", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "React Hooks library for remote data fetching", | ||
@@ -110,3 +110,3 @@ "keywords": [ | ||
"@playwright/test": "^1.30.0", | ||
"swr": "2.1.1" | ||
"swr": "2.1.2" | ||
}, | ||
@@ -124,5 +124,2 @@ "peerDependencies": { | ||
}, | ||
"engines": { | ||
"pnpm": "7" | ||
}, | ||
"dependencies": { | ||
@@ -129,0 +126,0 @@ "use-sync-external-store": "^1.2.0" |
import { Key, SWRConfiguration, Middleware } from 'swr'; | ||
type SWRSubscription<Data = any, Error = any> = (key: Key, { next }: { | ||
type SWRSubscriptionOptions<Data = any, Error = any> = { | ||
next: (err?: Error | null, data?: Data) => void; | ||
}) => () => void; | ||
}; | ||
type SWRSubscription<SWRSubKey extends Key = Key, Data = any, Error = any> = SWRSubKey extends () => infer Arg | null | undefined | false ? (key: Arg, { next }: SWRSubscriptionOptions<Data, Error>) => void : SWRSubKey extends null | undefined | false ? never : SWRSubKey extends infer Arg ? (key: Arg, { next }: SWRSubscriptionOptions<Data, Error>) => void : never; | ||
type SWRSubscriptionResponse<Data = any, Error = any> = { | ||
@@ -10,3 +11,4 @@ data?: Data; | ||
}; | ||
type SWRSubscriptionHook<Data = any, Error = any> = (key: Key, subscribe: SWRSubscription<Data, Error>, config?: SWRConfiguration) => SWRSubscriptionResponse<Data, Error>; | ||
type SWRSubscriptionHook = <Data = any, Error = any, SWRSubKey extends Key = Key>(key: SWRSubKey, subscribe: SWRSubscription<SWRSubKey, Data, Error>, config?: SWRConfiguration) => SWRSubscriptionResponse<Data, Error>; | ||
declare const subscription: Middleware; | ||
@@ -28,4 +30,4 @@ /** | ||
*/ | ||
declare const useSWRSubscription: SWRSubscriptionHook<any, any>; | ||
declare const useSWRSubscription: SWRSubscriptionHook; | ||
export { SWRSubscription, SWRSubscriptionHook, SWRSubscriptionResponse, useSWRSubscription as default, subscription }; | ||
export { SWRSubscription, SWRSubscriptionHook, SWRSubscriptionOptions, SWRSubscriptionResponse, useSWRSubscription as default, subscription }; |
247344
5534