I see a very common pattern of using 2 properties,...
# language-proposals
v
I see a very common pattern of using 2 properties, private and public, when exposing a mutable container as a read-only interface. Example with Android
LiveData
(a kind of observable):
Copy code
private val _volume = MutableLiveData(0)
public val volume: LiveData<Int> = _volume
Example with lists:
Copy code
private val _users = mutableListOf(user1)
public val users: List<User> = _users
Are there any ideas that are on the table that would simplify those patterns or allow them to be encapsulated with property delegates?
@Ruckus in what channel should I ask if somebody is working on a specific idea?
I understand the concerns with Q/A. In fact, initially my post was intended as a proposal description, but after I wrote it I deleted my solution (with delegates) and just left the problem description. I think that helped people point me into the right direction of an existing KEEP instead of discussing my inferior proposal
i
@Ruckus This discussion started with a use case, so I think it's on-topic here.
m
As answer to the question: https://github.com/Kotlin/KEEP/pull/122 And I would suggest the relatively new channel #language-evolution for questions. I think it's kind of the purpose of that one.