Skip to content

Commit 76981f0

Browse files
committed
- improve README to include note on scroll state
1 parent 818f315 commit 76981f0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,16 @@ Markdown(markdownState)
122122

123123
### Parse Markdown in VM
124124

125+
> [!NOTE]
126+
> This approach is also advised if you want to retain scroll position even when navigating away
127+
> See: https://github.com/mikepenz/multiplatform-markdown-renderer/issues/374
128+
> Retaining state in the VM ensures parsing will not have to be done again, and the component can be
129+
> immediately filled.
130+
125131
```kotlin
126132
// In the VM setup the flow to parse the markdown
127133
val markdownFlow = parseMarkdownFlow("# Markdown")
134+
.stateIn(lifecycleScope, SharingStarted.Eagerly, State.Loading())
128135

129136
// In the Composable use the flow
130137
val state by markdownFlow.collectAsStateWithLifecycle(State.Loading())

0 commit comments

Comments
 (0)