Giter Site home page Giter Site logo

Comments (2)

arkivanov avatar arkivanov commented on May 11, 2024

Perhaps RawValue wouldn't help in all cases, because the data would be written with writeValue. It may crash at runtime if the actual type is not supported by writeValue.

You can try making T : Parcelable, if that's possible. However this may also not be working in some cases, e.g. when the actual class is in another ClassLoader.

A rule of thumb is to avoid generic types. You can make UIState not Parcelable, and parcelize it manually in every case where you otherwise specify the actual T. E.g. you can transform UIState<SomeClass> to a custom SavedUiStateWithSomeClass : Parcelable.

If you need this logic in the base code (where UIState is defined), then you can try supplying additional functions to save and restore UIState<T>. E.g. this could be:

  • saveState: (UIState<T>) -> ParcelableContainer
  • restoreState: (ParcelableContainer) -> UIState<T>

Check out how it is done in Decompose.

from essenty.

avidraghavMM avatar avidraghavMM commented on May 11, 2024

Thanks for the quick reply I got it.

from essenty.

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.