Starting

What is Preview? It’s a functionality that gives your an opportunity for view a composable UI during development without the need to build and run on an emulator. (If you use the Android Studio obviously)

Problem

In fact you must have a some data that you wanna see in preview. But sometimes it’s impossible.

Imagine, you have a screen like this:

@Composable
fun SomeScreen(
viewModel: SomeViewModel = hiltViewModel(),
){
//some UI
}

And view model of that screen like this:

class SomeViewModel @Inject constructor(
private val someUseCase1: someUseCase1,
private val someUseCase2: someUseCase2
//etc
) : ViewModel() {

val someDataFLow1 = someUseCase1.getSomeData()
.stateIn(
scope = viewModelScope,
started = SharingStarted.WhileSubscribed(5_000),
initia...

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help