GodotNuts / GodotFirebase

Implementations of Firebase for Godot using GDScript
MIT License
553 stars 79 forks source link

Dev #249

Closed fenix-hub closed 3 years ago

fenix-hub commented 3 years ago

Fixes #246 #247

to fix #246 FirestoreTask needed to be updated: task_finished signal always returned a document, even if the task was not successful. This caused Godot to crash if the result of yield(task, "task_finished") was typed to var result : FirestoreDocument.

Now task_finished returns the task itself ->

var task : FirestoreTask = yield(task, "task_finished")
- or just -
yield(task, "task_finished")

then you can check if the task was successful or not like so

yield(task, "task_finished")
if (task.error.empty()):
  # successful path
  task.data # Dictionary or Array ...
  task.document # FirestoreDocument ...
else:
  # unsuccessful path

properties: FirestoreTask.error -> empty if task was successful, otherwise is a Dictionary FirestoreTask.data -> data returned by a successful task, otherwise empty (could be Array or Dictionary depending on the task) FirestoreTask.document -> contains a non-null FirestoreDocument if the task result is a single document