Skip to content

Instantly share code, notes, and snippets.

@manuelvicnt
Created May 3, 2021 12:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manuelvicnt/de2a31d207a606bdb2240d33cdc00c72 to your computer and use it in GitHub Desktop.
Save manuelvicnt/de2a31d207a606bdb2240d33cdc00c72 to your computer and use it in GitHub Desktop.
class UserRepository(
private val userEventsDataSource: FirestoreUserEventDataSource
) {
// New collectors will register as a new callback in Firestore.
// As this function depends on a `userId`, the flow cannot be
// reused by calling shareIn or stateIn in this function.
// That will cause a new Shared/StateFlow to be created
// every time the function is called.
fun getUserEvents(userId: String): Flow<UserEventsResult> =
userLocalDataSource.getObservableUserEvents(userId)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment