8000 add unsubscribe · homebaseio/homebase-react@23bc70d · GitHub
[go: up one dir, main page]

Skip to content

Commit 23bc70d

Browse files
committed
add unsubscribe
1 parent a3d663d commit 23bc70d

File tree

1 file changed

+3
-23
lines changed
  • examples/typescript-supabase-todo/src

1 8000 file changed

+3
-23
lines changed

examples/typescript-supabase-todo/src/Todos.tsx

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export default function Todos(user) {
1414
return(
1515
<div>
1616
<DataSaver user={user}/>
17-
<SignOut />
1817
<NewTodo />
1918
<hr/>
2019
<TodoFilters />
@@ -81,41 +80,22 @@ const DataSaver = (user) => {
8180
});
8281
}
8382
});
84-
//TK
85-
console.log(client.transactSilently)
86-
client.addTransactListener(transactListener)
8783
const on = (action: any) => (ds: any) => client.transactSilently([[action, ...ds.val()]])
8884
subscription1 = supabase
8985
.from('entities')
9086
.on('UPDATE', (v) => on('add'))
9187
.on('INSERT', (v) => on('add'))
9288
.on('DELETE', (v) => on('retract') )
9389
.subscribe((change) => console.log('todos changed', change))
94-
/*
90+
9591
return () => {
9692
client.removeTransactListener()
97-
ref.off('child_added', on('add'))
98-
ref.off('child_removed', on('retract'))
99-
ref.off('child_changed', on('add'))
100-
}*/
93+
supabase.removeSubscription(subscription1)
94+
}
10195
}, [userId])
10296
return null
10397
}
10498

105-
const SignOut = () => {
106-
const [client] = useClient()
107-
return (
108-
<button
109-
style={{float: 'right'}}
110-
onClick={() => {
111-
112-
client.dbFromString(window.emptyDB)
113-
firebase.auth().signOut()
114-
}}
115-
>Sign Out</button>
116-
)
117-
}
118-
11999
const NewTodo = () => {
120100
const [transact] = useTransact()
121101
return (

0 commit comments

Comments
 (0)
0