Skip to content

Instantly share code, notes, and snippets.

@skydoves
Last active September 13, 2024 04:15
Show Gist options
  • Save skydoves/b28d1a771cc0a1d6be72c6301cdaa644 to your computer and use it in GitHub Desktop.
Save skydoves/b28d1a771cc0a1d6be72c6301cdaa644 to your computer and use it in GitHub Desktop.
flow_ktx
internal class TimelineRepositoryImpl @Inject constructor(
private val databaseReference: DatabaseReference,
private val json: Json
) : TimelineRepository {
override fun fetchTimelineUi(): Flow<Result<TimelineUi?>> {
return databaseReference.flow(
path = { snapshot ->
snapshot.child("timeline")
},
decodeProvider = { jsonString ->
json.decodeFromString(jsonString)
}
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment