Code Monkey home page Code Monkey logo

Comments (5)

Kadanza avatar Kadanza commented on May 18, 2024

point 4 :
some device have this error (with old api Android)

Nexus 6p - Android 8.1 doesn't have this mistake

from livedata-ktx.

henrytao-me avatar henrytao-me commented on May 18, 2024

Hi @Kadanza, I missed your original message. Thanks for reaching out. Hopefully, I can address some of your questions below:

  1. what improvement has version 3.0.0?
  2. why need MutableLiveDataKtx instead MutableLiveData?

As listed in the README, v3 focuses on Kotlin friendly, preserve immutability, and extensibility. For instance, you still can set null value for a non-null LiveData which can cause NPE at runtime. Compiler should be able to prevent it.

// Allow to set null value to LiveData
val liveData = MutableLiveData<Boolean>()
liveData.value = null

// LiveDataKtx doesn't allow to null value
val liveData = MutableLiveDataKtx<Boolean>()
liveData.value = null // doesn't allow

// Set nullable in LiveDataKtx
val liveData = MutableLiveDataKtx<Boolean?>()
liveData.value = null
  1. In version 2.0 we has great extension observe without Observer

There is tradeoffs for the approach. Kotlin lambda generates different object down to Java layer which makes harder to remove the observer later on.

  1. In version 2.0 I has unpleasant bug in android studio

I haven't encountered this issue. I can take a look later.

from livedata-ktx.

Kadanza avatar Kadanza commented on May 18, 2024

point 3 : are you not recommend use version 2 because of problem with memory?

I use version 2 widely

from livedata-ktx.

henrytao-me avatar henrytao-me commented on May 18, 2024

If you use v2.0.2, removeObserver should work properly as we had a fix for it https://github.com/Shopify/livedata-ktx/releases/tag/v2.0.2.

So, migrating to v3 is an optional.

from livedata-ktx.

henrytao-me avatar henrytao-me commented on May 18, 2024

Let us know if you have any other concerns. I will close this issue for now. Feel free to reopen if needed.

from livedata-ktx.

Related Issues (13)

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.