You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .gemini/styleguide.md
+6-2Lines changed: 6 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -73,7 +73,11 @@ sealed class ScreenState {
73
73
***Recommended:** Do not use `AndroidViewModel`. Use the `ViewModel` class. Avoid using the `Application` class in ViewModels; move the dependency to the UI or data layer.
74
74
***Recommended:** Don't use `LiveData`, use state flow instead.
75
75
***Recommended:** Expose a UI state. Use a single `uiState` property (a `StateFlow`) for data exposure. Multiple properties can be used for unrelated data. Use `stateIn` with `WhileSubscribed(5000)` for data streams. For simpler cases, use a `MutableStateFlow` exposed as an immutable `StateFlow`. Consider using a data class or sealed class for the `UiState`.
76
-
***Recommeded:** Don’t pass `Context` to your `ViewModel`. To avoid memory leaks only UI (Composables) should have a reference to `context`.
76
+
***Recommeded:** Don’t pass `Context` to your `ViewModel`. To avoid memory leaks only UI (Composables) should have a reference to `context`. If you really need to use `Context` in `ViewModel`, you can use AndroidViewModel instead which provides access to an Application context, e.g:
***Recommeded:** Don’t use `fetchData()` in a ViewModel `init {}` block. If you do end up in a case where you need to do something on initial load, you use `stateIn()` instead.
* Interface Implementations: Meaningful names. Prefix with `Default` if no better name is found (e.g., `OfflineFirstNewsRepository`, `InMemoryNewsRepository`, `DefaultNewsRepository`). Prefix fake implementations with `Fake` (e.g., `FakeAuthorsRepository`).
119
+
* Interface Implementations: Meaningful names. Prefix with `Default` if no better name is found (e.g., `OfflineFirstNewsRepository`, `InMemoryNewsRepository`, `DefaultNewsRepository`). Prefix fake implementations with `Fake` (e.g., `FakeAuthorsRepository`).
0 commit comments