@@ -29,10 +29,12 @@ var _db_path : String
2929var _cached_filter : String
3030var _push_queue : Array = []
3131var _update_queue : Array = []
32+ var _delete_queue : Array = []
3233var _can_connect_to_host : bool = false
3334
3435const _put_tag : String = "put"
3536const _patch_tag : String = "patch"
37+ const _delete_tag : String = "delete"
3638const _separator : String = "/"
3739const _json_list_tag : String = ".json"
3840const _query_tag : String = "?"
@@ -83,6 +85,8 @@ func on_new_sse_event(headers : Dictionary, event : String, data : Dictionary) -
8385 emit_signal ("new_data_update" , FirebaseResource .new (data .path , data .data ))
8486 elif command == _patch_tag :
8587 emit_signal ("patch_data_update" , FirebaseResource .new (data .path , data .data ))
88+ elif command == _delete_tag :
89+ emit_signal ("delete_data_update" , FirebaseResource .new (data .path , data .data ))
8690 pass
8791
8892func set_store (store_ref : FirebaseDatabaseStore ) -> void :
@@ -111,6 +115,12 @@ func push(data : Dictionary) -> void:
111115 else :
112116 _push_queue .append (data )
113117
118+ func delete (reference : String ) -> void :
119+ if _pusher .get_http_client_status () == HTTPClient .STATUS_DISCONNECTED :
120+ _pusher .request (_get_list_url () + _db_path + _separator + reference + _get_remaining_path (), _headers , true , HTTPClient .METHOD_DELETE , "" )
121+ else :
122+ _delete_queue .append (reference )
123+
114124#
115125# Returns a deep copy of the current local copy of the data stored at this reference in the Firebase
116126# Realtime Database.
@@ -156,6 +166,8 @@ func _route_data(command : String, path : String, data) -> void:
156166 _store .put (path , data )
157167 elif command == _patch_tag :
158168 _store .patch (path , data )
169+ elif command == _delete_tag :
170+ _store .delete (path , data )
159171
160172func on_push_request_complete (result : int , response_code : int , headers : PoolStringArray , body : PoolByteArray ) -> void :
161173 if response_code == HTTPClient .RESPONSE_OK :
@@ -168,4 +180,7 @@ func on_push_request_complete(result : int, response_code : int, headers : PoolS
168180 return
169181 if _update_queue .size () > 0 :
170182 var e = _update_queue .pop_front ()
171- update (e ['path' ], e ['data' ])
183+ update (e ['path' ], e ['data' ])
184+ return
185+ if _delete_queue .size () > 0 :
186+ delete (_delete_queue .pop_front ())
0 commit comments