Is there any neat way of doing ``` private val...
# announcements
p
Is there any neat way of doing
Copy code
private val _title = BehaviorRelay.create<String>()
    val title: Observable<String> = _title
without the backing property?
🧵 1
h
You're trying to expose
title
as a
Observable<String>
rather than a
BehaviorRelay<String>
but still want access to it within the class as
BehaviorRelay<String>
ya? Nope thats how I do it
p
Yes, this is exactly what I want.
h
No better way currently, there's a related KEEP though: https://github.com/Kotlin/KEEP/pull/122
r
The private backing property should be optimized away (no getters or setters), and if you change the public accessor to
val title: Observable<String> get() = _title
it won't creating a backing field, so it should be just as "optimized" as clean Java.
👍 3