11from typing import Any , Callable
22
33from realtime_py .connection import Socket
4+ from realtime_py .transformers import convert_change_data
45
56
67class SupabaseRealtimeClient :
7- def __init__ (self , socket , schema , table_name ):
8+ def __init__ (self , socket : Type [ Socket ] , schema : str , table_name : str ):
89 topic = (
910 f"realtime:{ schema } "
1011 if table_name == "*"
@@ -14,11 +15,12 @@ def __init__(self, socket, schema, table_name):
1415
1516 def get_payload_records (self , payload : Any ):
1617 records = {"new" : {}, "old" : {}}
17- # TODO: Figure out how to create payload
18- # if payload.type == "INSERT" or payload.type == "UPDATE":
19- # records.new = Transformers.convertChangeData(payload.columns, payload.record)
20- # if (payload.type === 'UPDATE' || payload.type === 'DELETE'):
21- # records.old = Transformers.convertChangeData(payload.columns, payload.old_record)
18+ if payload .type == "INSERT" or payload .type == "UPDATE" :
19+ records .new = payload .record
20+ convert_change_data (payload .columns , payload .record )
21+ if (payload .type == = 'UPDATE' or payload .type == = 'DELETE' ):
22+ records .old = payload .record
23+ convert_change_data (payload .columns , payload .old_record )
2224 return records
2325
2426 def on (self , event , callback : Callable [..., Any ]):
0 commit comments