A. Missing .subscribe() call to activate subscription
B. Wrong event type; should be 'REMOVE' instead of 'DELETE'
C. Callback function must receive a payload parameter
D. Subscription must be assigned to a variable named 'sub'
Solution
Step 1: Check subscription activation
The .subscribe() method is required to start listening to events.
Step 2: Verify event type and callback
'DELETE' is a valid event, and callback can omit payload if unused.
Final Answer:
Missing .subscribe() call to activate subscription -> Option A
Quick Check:
Always call .subscribe() to activate [OK]
Hint: Always end with .subscribe() to start listening [OK]
Common Mistakes:
Forgetting .subscribe() call
Using wrong event names
Thinking callback must have parameters
5. You want to subscribe to both INSERT and UPDATE events on the 'profiles' table and log the changed row each time. Which code correctly achieves this?
hard
A. supabase.from('profiles').on('INSERT,UPDATE', payload => console.log(payload.new)).subscribe()
B. supabase.from('profiles').on(['INSERT', 'UPDATE'], payload => console.log(payload.new)).subscribe()
C. supabase.from('profiles').on('INSERT', payload => console.log(payload.new)).on('UPDATE', payload => console.log(payload.new)).subscribe()
D. supabase.from('profiles').on('INSERT').on('UPDATE', payload => console.log(payload.new)).subscribe()
Solution
Step 1: Understand event subscription chaining
Supabase allows chaining .on() calls for different events before .subscribe().