Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error handler callback #13

Open
workhorsy opened this issue Aug 26, 2022 · 0 comments
Open

Add error handler callback #13

workhorsy opened this issue Aug 26, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@workhorsy
Copy link
Member

workhorsy commented Aug 26, 2022

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" ))
@workhorsy workhorsy added the enhancement New feature or request label Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant