Skip to content

Add error handler callback #13

@workhorsy

Description

@workhorsy

Because AsyncLoader.load_scene_async_with_cb is async, there is a chance that the target, instance, and cb have been deleted before use. So we would have to do a bunch of checks for each callback. Rather than do that, have a callback that is called on any of these situations.

func _on_orange_loaded_cb(instance : Node, data : Dictionary) -> void:
	# Just return if target is invalid
	if not is_instance_valid(target):
		return

	# Just return if instance is invalid
	if not is_instance_valid(instance):
		return

	# Just return if the cb is invalid
	if cb != null and not cb.is_valid():
		return
func _on_error(instance : Node, data : Dictionary) -> void:
	# Just return if target is invalid
	if not is_instance_valid(target):
		return

	# Just return if instance is invalid
	if not is_instance_valid(instance):
		return

	# Just return if the cb is invalid
	if cb != null and not cb.is_valid():
		return

AsyncLoader.start(groups, 100, funcref(self,"_on_error" ))

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions