From 1c609b3bc734bdea3ff0a1c5d9d04dd353d69629 Mon Sep 17 00:00:00 2001 From: Alfred Sultson <11300079+sultson@users.noreply.github.com> Date: Mon, 21 Aug 2023 23:15:40 +0200 Subject: [PATCH 1/4] Update custom-cache-updates.mdx to fix useUpsertItem examples naming --- docs/pages/postgrest/custom-cache-updates.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/pages/postgrest/custom-cache-updates.mdx b/docs/pages/postgrest/custom-cache-updates.mdx index a7d77eba..e08591ed 100644 --- a/docs/pages/postgrest/custom-cache-updates.mdx +++ b/docs/pages/postgrest/custom-cache-updates.mdx @@ -56,7 +56,7 @@ Upsert a postgrest entity into the cache. Note that you have to pass a value for import { useUpsertItem } from "@supabase-cache-helpers/postgrest-swr"; function Page() { - const deleteItem = useDeleteItem({ + const upsertItem = useUpsertItem({ primaryKeys: ['id'], table: 'contact', schema: 'public', @@ -73,7 +73,7 @@ Upsert a postgrest entity into the cache. Note that you have to pass a value for import { useUpsertItem } from "@supabase-cache-helpers/postgrest-react-query"; function Page() { - const deleteItem = useDeleteItem({ + const upsertItem = useUpsertItem({ primaryKeys: ['id'], table: 'contact', schema: 'public', From fbf8d34daa405077986db47b6dee875a22dd8021 Mon Sep 17 00:00:00 2001 From: Alfred Sultson <11300079+sultson@users.noreply.github.com> Date: Mon, 21 Aug 2023 23:32:02 +0200 Subject: [PATCH 2/4] Update getting-started.mdx to reflect refactored useSubscription + clarify the need to insert differing channel names --- docs/pages/postgrest/getting-started.mdx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/pages/postgrest/getting-started.mdx b/docs/pages/postgrest/getting-started.mdx index 9f720983..d7c63418 100644 --- a/docs/pages/postgrest/getting-started.mdx +++ b/docs/pages/postgrest/getting-started.mdx @@ -145,7 +145,8 @@ The query cache will automatically be updated when new data comes in. If you use function Page() { const { status } = useSubscription( - client.channel("random"), + client, + `insert-channel-name`, { event: "*", table: "contact", @@ -170,7 +171,8 @@ The query cache will automatically be updated when new data comes in. If you use function Page() { const { status } = useSubscription( - client.channel("random"), + client, + `insert-channel-name`, { event: "*", table: "contact", From 8053835041d2f7508f8848a89c4a1f361df1c6b9 Mon Sep 17 00:00:00 2001 From: Alfred Sultson <11300079+sultson@users.noreply.github.com> Date: Mon, 21 Aug 2023 23:38:00 +0200 Subject: [PATCH 3/4] Update subscriptions.mdx to clarify need for unique channel names when using multiple useSubscription hooks --- docs/pages/postgrest/subscriptions.mdx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/pages/postgrest/subscriptions.mdx b/docs/pages/postgrest/subscriptions.mdx index 886a8ed4..aaa1efd1 100644 --- a/docs/pages/postgrest/subscriptions.mdx +++ b/docs/pages/postgrest/subscriptions.mdx @@ -6,8 +6,7 @@ The cache helpers subscription hooks are simple `useEffect`-based hooks that man ## `useSubscription` -The `useSubscription` hook simply manages a realtime subscription. Upon retrieval of an update, it updates the cache with the retrieved data the same way the mutation hooks do. It exposes all params of the .on() method, including the callback, as well as the mutation options of the respective library. - +The `useSubscription` hook simply manages a realtime subscription. Upon retrieval of an update, it updates the cache with the retrieved data the same way the mutation hooks do. It exposes all params of the .on() method, including the callback, as well as the mutation options of the respective library. NOTE: Channel names must be unique when using multiple subscription hooks. ```tsx @@ -23,7 +22,7 @@ The `useSubscription` hook simply manages a realtime subscription. Upon retrieva function Page() { const { status } = useSubscription( client, - `random`, + `insert-channel-name`, { event: '*', table: 'contact', @@ -52,7 +51,7 @@ The `useSubscription` hook simply manages a realtime subscription. Upon retrieva function Page() { const { status } = useSubscription( client, - `random`, + `insert-channel-name`, { event: '*', table: 'contact', @@ -88,7 +87,7 @@ The `useSubscriptionQuery` hook does exactly the same as the `useSubscription` h function Page() { const { status } = useSubscriptionQuery( client, - `random`, + `insert-channel-name`, { event: '*', table: 'contact', @@ -118,7 +117,7 @@ The `useSubscriptionQuery` hook does exactly the same as the `useSubscription` h function Page() { const { status } = useSubscriptionQuery( client, - `random`, + `insert-channel-name`, { event: '*', table: 'contact', From f51a34f5c870ed12c2dc9e6bf8c0609ce8e53b4d Mon Sep 17 00:00:00 2001 From: psteinroe Date: Tue, 12 Sep 2023 12:03:12 +0200 Subject: [PATCH 4/4] fix: format --- docs/pages/postgrest/subscriptions.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/pages/postgrest/subscriptions.mdx b/docs/pages/postgrest/subscriptions.mdx index aaa1efd1..16b95f58 100644 --- a/docs/pages/postgrest/subscriptions.mdx +++ b/docs/pages/postgrest/subscriptions.mdx @@ -7,6 +7,7 @@ The cache helpers subscription hooks are simple `useEffect`-based hooks that man ## `useSubscription` The `useSubscription` hook simply manages a realtime subscription. Upon retrieval of an update, it updates the cache with the retrieved data the same way the mutation hooks do. It exposes all params of the .on() method, including the callback, as well as the mutation options of the respective library. NOTE: Channel names must be unique when using multiple subscription hooks. + ```tsx