Skip to content
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

Add support for explicit backing fields #277

Closed
wants to merge 6 commits into from

Conversation

lunakoly
Copy link
Member

@lunakoly lunakoly commented Sep 15, 2021

Please, see explicit-backing-fields.md for the full text.

The corresponding issue.

@mglukhikh mglukhikh self-requested a review September 16, 2021 08:15

```kotlin
val it: A
[visibility] field[: B] = initializer
Copy link
Contributor

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
Copy link
Contributor

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>.

Copy link
Member Author

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)

@elizarov
Copy link
Contributor

elizarov commented Feb 2, 2022

Superseded by #289. Please, add any further comments on the proposed text there.

@elizarov elizarov closed this Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants