Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

180
Views
Datos en vivo: la resolución del candidato se cambiará pronto

En los mismos casos, el estudio de Android muestra un mensaje de advertencia cuando llamo al método de observe del objeto LiveData

 viewModel.emailValidationResult.observe(viewLifecycleOwner, {onEmailChanged(it)})

La resolución del candidato se cambiará pronto, utilice un nombre completo para invocar explícitamente al siguiente candidato más cercano:

public open fun observe(propietario: LifecycleOwner, observador: Observer<in Int?>): Unidad definida en androidx.lifecycle.LiveData

Según tengo entendido, sucedió después de actualizar kotlin 1.4 ¿Qué significa realmente?

over 4 years ago · Hanz Gallego
5 answers
Answer question

0

El mismo problema también ocurrió en mi base de código. La versión de kotlin es '1.4.32'

Después de eliminar el sentimiento de importación a continuación, la advertencia desapareció.

 import androidx.lifecycle.observe
over 4 years ago · Hanz Gallego Report

0

En mi caso, utilicé Kotlin 1.4.31 en el archivo buildgradle (nivel de proyecto).

 ext { kotlin_version = '1.4.31' } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" }

El error de advertencia/desaprobación desapareció.

over 4 years ago · Hanz Gallego Report

0

Intenté eliminar "importar androidx.lifecycle.observe" y convertí a nuestros observadores de la siguiente manera:

 // From this livedata.observe(viewLifecycleOwner, Observer<MyClass?> { // do stuff with it }) // To this livedata.observe(viewLifecycleOwner) { // do stuff with it }

El problema ocurrió cuando necesitamos eliminar el observador dentro de la llamada onChange, por ejemplo

 // From this livedata.observe(viewLifecycleOwner, object : Observer<MyClass?> { override fun onChanged(t: MyClass?) { // Do stuff with it t livedata.removeObserver(this) } }) // To this livedata.observe(viewLifecycleOwner) { // do stuff with it livedata.removeObserver(this) <--- not working ofc }

Escuché rumores de que la gente ha desglosado el observador como una variable y, por lo tanto, ha podido agregarlo/eliminarlo haciendo referencia a la variable. Sin embargo, no puedo averiguar cómo crear una instancia de un observador local sin usar la sintaxis "Observer<MyClass?>.

over 4 years ago · Hanz Gallego Report

0

La extensión de AndroidX está obsoleta, por lo que debemos usar la original.

Quitar import androidx.lifecycle.observe

luego

 viewModel.liveData.observe(viewLifecycleOwner, Observer { result -> })

o

 viewModel.liveData.observe(viewLifecycleOwner) { result -> }
over 4 years ago · Hanz Gallego Report

0

Significa que la extensión en androidx ya no es necesaria.

Simplemente elimine su import import androidx.lifecycle.observe .

En realidad, quedará obsoleto en androidx. Lea más razonamiento allí.

EDITAR:

Tenga en cuenta el "problema" de Erik Hoogendoorn

Este cambio hace que los valores del objeto LiveData observado se interpreten como anulables (dado que la sintaxis lambda convertida se basa en código Java anulable). Este no fue el caso de la extensión de Kotlin y provoca una pérdida de funcionalidad para el usuario. En mi opinión, este cambio debería revertirse y encontrar una solución diferente.

Tengo curiosidad por saber si cambiarán el nombre y conservarán el ayudante o si encontrarán otra solución.

over 4 years ago · Hanz Gallego Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!