-
Notifications
You must be signed in to change notification settings - Fork 368
Add support for explicit backing fields #277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
proposals/explicit-backing-fields.md
Outdated
|
||
```kotlin | ||
val it: A | ||
[visibility] field[: B] = initializer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure here but may be it's better to rename A
to P
(property) and B
to F
(field). This allows easier understanding of these abbreviations, especially in text far below.
field = MutableLiveData() | ||
``` | ||
|
||
### RX Observable and Subjects |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it is already the year 2021 (and also taking into account readers from the future), it is way better to give this example using Kotlin Flow instead of Rx, e.g. with MutableStateFlow<String>
that is exposed as StateFlow<String>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example would, indeed, illustrate the use of an explicit backing field, but since it's typical to use asStateFlow()
, the smart type narrowing wouldn't work, and the example would be a bit misleading (apart from the STN there's currently no way to access the field value from outside the accessors)
Superseded by #289. Please, add any further comments on the proposed text there. |
Please, see explicit-backing-fields.md for the full text.
The corresponding issue.