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?
r
Please adhere to the channel topic:
All discussion in this channel should begin with a use-case or proposal instead of a question.
v
@Ruckus in what channel should I ask if somebody is working on a specific idea?
r
I usually ask in #general, but you could also have just stated your proposal and people will let you know if there's an open discussion for it somewhere.
I know that's not the most helpful of answers, but this channel was specifically created (as least as far as I understand it) to avoid the issue in other channels where proposals were getting drowned out by Q/A and discussion.
v
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.
r
Fair enough. I guess I was too focused on the question mark.
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.