Skip to content

Commit

Permalink
simpilify code
Browse files Browse the repository at this point in the history
  • Loading branch information
promer94 committed Jul 13, 2023
1 parent 5f6a735 commit ff5267c
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions subscription/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export const subscription = (<Data = any, Error = any>(useSWRNext: SWRHook) =>
config: SWRConfiguration & typeof SWRConfig.defaultValue
): SWRSubscriptionResponse<Data, Error> => {
const [key, args] = serialize(_key)
const originKey = args

// Prefix the key to avoid conflicts with other SWR resources.
const subscriptionKey = key ? SUBSCRIPTION_PREFIX + key : undefined
Expand Down Expand Up @@ -68,7 +67,7 @@ export const subscription = (<Data = any, Error = any>(useSWRNext: SWRHook) =>
subscriptions.set(subscriptionKey, refCount + 1)

if (!refCount) {
const dispose = subscribe(originKey, { next })
const dispose = subscribe(args, { next })
if (typeof dispose !== 'function') {
throw new Error(
'The `subscribe` function must return a function to unsubscribe.'
Expand Down

0 comments on commit ff5267c

Please sign in to comment.