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

Feat improve java interop #579

Merged
merged 15 commits into from
Nov 11, 2022
Merged

Feat improve java interop #579

merged 15 commits into from
Nov 11, 2022

Conversation

abnegate
Copy link
Contributor

What does this PR do?

Add coroutine continuation wrapper for easier use from Java

Before:

        account.get(new Continuation<io.appwrite.models.Account>() {
            @NonNull
            @Override
            public CoroutineContext getContext() {
                return EmptyCoroutineContext.INSTANCE;
            }

            @Override
            public void resumeWith(@NonNull Object o) {
                if (o instanceof Result.Failure) {
                    Result.Failure failure = (Result.Failure) o;
                    failure.exception.printStackTrace();
                    return;
                }
                
                System.out.println((io.appwrite.models.Account) o);
            }
        });

After:

        account.get(new CoroutineCallback<>((account, error) -> {
            if (error != null) {
                error.printStackTrace();
                return;
            }

            System.out.println(account)
        }));

Test Plan

Manual test

Related PRs and Issues

Supercedes #575

Have you read the Contributing Guidelines on issues?

Yes

Copy link
Contributor

@stnguyen90 stnguyen90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't test any of this and I know barely anything about Continuations, but the syntax looks great! It's really clean!

I'm only concerned about how much it will bother people with there being such a breaking change 😕

templates/swift/docs/example.md.twig Show resolved Hide resolved
@abnegate
Copy link
Contributor Author

I'm only concerned about how much it will bother people with there being such a breaking change 😕

@stnguyen90 It's not breaking 😉 CoroutineCallback extends Continuation so you can pass either

…nterop

# Conflicts:
#	templates/android/docs/java/example.md.twig
#	templates/android/docs/kotlin/example.md.twig
#	templates/kotlin/docs/java/example.md.twig
#	templates/kotlin/docs/kotlin/example.md.twig
#	templates/swift/docs/example.md.twig
@lohanidamodar lohanidamodar merged commit 3441fa9 into master Nov 11, 2022
@lohanidamodar lohanidamodar deleted the feat-improve-java-interop branch November 11, 2022 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants