Closed stmn closed 1 year ago
Sorry, that 'sign in' problem should be fixed better. I'm looking for better way.
Hi @stmn
thanks for all your contributions!
The issue with the tasks routines not working with the gdscript style is that since latest betas of Godot 4.0 RefCounted
classes are handled differently.
Eventually any reference to the BaseTask
is lost and the task is not processed anymore, so the signal will httprequest.completed
signal will never be executed.
In my opinion there's no necessity to change the codebase for now, returning a Signal (which will never be directly used), or adding the await
in the inner functions (since this will force asynchronous calls to be synchronous anyway).
Instead manually referencing and unreferencing should work.
# base_task.gd
func push_request(httprequest : HTTPRequest) -> void:
+ reference()
httprequest.request_completed.connect(_on_task_completed.bind(httprequest))
httprequest.request(_endpoint, _headers, true, _method, _payload)
func _on_task_completed(result : int, response_code : int, headers : PackedStringArray, body : PackedByteArray, handler: HTTPRequest) -> void:
pass
func _complete(_data = null, _error : BaseError = null) -> void:
data = _data
error = _error
completed.emit(self)
+ unreference()
would you mind making a quick check?
@fenix-hub It works, commited.
Reason:
Reason:
Reason:
And that _on_signed is not executed. These awaits makes that sign in is working properly and _on_signed is executed. It fix only GDScript style, JS style don't need that fix.
Looks like example from readme.md not working also without that awaits.