https://kotlinlang.org logo
#announcements
Title
# announcements
d

david.bilik

06/19/2017, 1:55 PM
hello, why custom setters for private properties are not called inside lambdas? For public property its ok but for private property its set directly without setter (checked via decompiling bytecode to java) .. relevant code
Copy code
private var cartProducts: List<CartProduct> = listOf()
   set(value) {
       field = value
       // show value in UI
    }
    
init {
	   productsRepository.observeProducts()
                .subscribe({
                    cartProducts = it.map { CartProduct(it, Random().nextInt(10) + 1) }
                }, { it.printStackTrace() })
}
the setter for cartProducts is not called
r

radityagumay

06/19/2017, 2:49 PM
david.bilik: what are doing here. Make a observer call in init.
2 Views