Code Monkey home page Code Monkey logo

Comments (8)

Burf2k avatar Burf2k commented on June 11, 2024 2

Thanks, glad I was not using Fold wrong

from cognito-idp.

Burf2k avatar Burf2k commented on June 11, 2024

I asked StackoverFlow and that answer doesn't work, there must be a way to return something useful
https://stackoverflow.com/questions/76101500/kotlin-returning-an-object-from-a-fold-closure/76103361#76103361

from cognito-idp.

benjohnde avatar benjohnde commented on June 11, 2024

This is more a question on Kotlin and how to work with suspend / Coroutines. But seeing the latest answer in this SO post I would infer that your problem is solved.

from cognito-idp.

Burf2k avatar Burf2k commented on June 11, 2024

Thank you Ben, I just assumed there was a way we could use onSuccess and onFailure

from cognito-idp.

gaebel avatar gaebel commented on June 11, 2024

Hi @Burf2k, there's indeed an issue with the fold extension. Since kotlin.Result couldn't get returned in the past and type information still gets lost when exported, we implemented our own Result type. Our fold extension doesn't return anything from onSuccess and onFailure.

https://github.com/Liftric/cognito-idp/blob/master/src/commonMain/kotlin/com/liftric/cognito/idp/core/Result.kt

from cognito-idp.

Burf2k avatar Burf2k commented on June 11, 2024

So do I need to use your library or wait for a fix?

from cognito-idp.

gaebel avatar gaebel commented on June 11, 2024

You could use getOrThrow to get the user, and wrap the call in a try/catch block to handle exceptions.

from cognito-idp.

Ingwersaft avatar Ingwersaft commented on June 11, 2024

Fold is just like a promise in the JS world, you could wrap the "callbacks" with suspendCancellableCoroutine

from cognito-idp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.