Skip to content

Commit

Permalink
Merge pull request #274 from sultson/main
Browse files Browse the repository at this point in the history
Fix docs to improve guidance on subscription hooks usage
  • Loading branch information
psteinroe committed Sep 12, 2023
2 parents c426015 + f51a34f commit 38d945c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions docs/pages/postgrest/custom-cache-updates.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down
6 changes: 4 additions & 2 deletions docs/pages/postgrest/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions docs/pages/postgrest/subscriptions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +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.

<Tabs items={['SWR', 'React Query']}>
<Tab>
Expand All @@ -23,7 +23,7 @@ The `useSubscription` hook simply manages a realtime subscription. Upon retrieva
function Page() {
const { status } = useSubscription(
client,
`random`,
`insert-channel-name`,
{
event: '*',
table: 'contact',
Expand Down Expand Up @@ -52,7 +52,7 @@ The `useSubscription` hook simply manages a realtime subscription. Upon retrieva
function Page() {
const { status } = useSubscription(
client,
`random`,
`insert-channel-name`,
{
event: '*',
table: 'contact',
Expand Down Expand Up @@ -88,7 +88,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',
Expand Down Expand Up @@ -118,7 +118,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',
Expand Down

3 comments on commit 38d945c

@vercel
Copy link

@vercel vercel bot commented on 38d945c Sep 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

supabase-cache-helpers-swr-demo – ./examples/swr

supabase-cache-helpers-swr-demo-psteinroe.vercel.app
supabase-cache-helpers-swr.vercel.app
supabase-cache-helpers-swr-demo-git-main-psteinroe.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 38d945c Sep 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 38d945c Sep 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

supabase-cache-helpers-react-query – ./examples/react-query

supabase-cache-helpers-react-query-psteinroe.vercel.app
supabase-cache-helpers-react-query.vercel.app
supabase-cache-helpers-react-query-git-main-psteinroe.vercel.app

Please sign in to comment.