GodotNuts / GodotFirebase

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

Add proper request queuing to Firestore #59

Closed fenix-hub closed 3 years ago

fenix-hub commented 3 years ago

A snippet for the implementation:

var requests_queue : Array = []

func add(documentId : String, fields : Dictionary = {}):
  if request != REQUESTS.NONE:
    requests_queue.add([REQUESTS.ADD, documentId, fields])
    return
   [...]

func on_pusher_request_complete(...) :
  [...]
  check_queue()

func check_queue():
  if requests_queue.size() > 0:
    var first_request = requests_queue().pop_front()
    match first_request:
      REQUESTS.ADD:
        add(first_request[1], first_request[2])

note: this is a temporary solution. A proper scalable solution will be implemented by @WolfgangSenff