Code Monkey home page Code Monkey logo

Comments (2)

Zhuinden avatar Zhuinden commented on July 3, 2024

Hey hey!

I added val uuid: UUID = UUID.randomUUID() to my data class, as suggested here: #261 (comment)
This works! However, this feels like a hacky solution, and I have to remember to add it to any key that could become part of a loop (i.e. appears in the backstack with the same parameters). Also, I'm not sure of the performance implications of using randomUUID() (probably insignificant, but it uses SecureRandom in its implementation).

Is there a better way to achieve this?

Well, you do need a stable string fragment tag (which is what data class + toString() does), I also do a val uuid: String = UUID.randomUUID().toString() when this is needed.

I'm not so sure it's that hacky, what the Google Navigation people do is that they have a static AtomicInteger being incremented so that each destination is indexed, but that wouldn't work well with asymmetric navigation actions (setHistory, bringToFront etc.) and I think it's way hackier than a uuid.

So if there's a better way, I don't know of it, but I do think this one makes sense. 😅

from simple-stack.

Stonos avatar Stonos commented on July 3, 2024

I see, thanks for the response!

from simple-stack.

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.