John O'Reilly
09/14/2023, 5:35 PMBruno Hensel
09/14/2023, 5:37 PMJohn O'Reilly
09/14/2023, 6:14 PMBruno Hensel
09/14/2023, 6:16 PMJohn O'Reilly
09/14/2023, 6:17 PMBruno Hensel
09/14/2023, 6:23 PMBruno Hensel
09/14/2023, 6:24 PMBruno Hensel
09/14/2023, 6:26 PMJohn O'Reilly
09/14/2023, 7:39 PMJohn O'Reilly
09/14/2023, 7:40 PMmbonnin
09/14/2023, 8:06 PMmbonnin
09/14/2023, 8:06 PMmbonnin
09/14/2023, 8:06 PMBruno Hensel
09/14/2023, 8:11 PMBruno Hensel
09/14/2023, 8:14 PMBruno Hensel
09/14/2023, 8:16 PMyschimke
09/15/2023, 2:28 PMOptimistic updates do not make a lot of sense. We need the local data to be the source of truthNot sure I agree when you have multiple devices 🙂
mbonnin
09/17/2023, 9:11 PMmbonnin
09/17/2023, 9:11 PMmbonnin
09/17/2023, 9:13 PMJohn O'Reilly
11/12/2023, 11:48 AMJohn O'Reilly
11/12/2023, 11:48 AMJohn O'Reilly
11/12/2023, 12:34 PMJohn O'Reilly
11/12/2023, 12:37 PMcollectAsStateWithLifecycle
John O'Reilly
11/12/2023, 12:41 PMSessionsComponent
(through following we have in SessionsRoute
).....do you know if that should be lifecycle aware?
val uiState by component.uiState.subscribeAsState()
Arkadii Ivanov
11/12/2023, 12:53 PMcollectAsStateWithLifecycle
only makes sense when the app is minimized to background. When the screen is in the back stack, its Composable is disposed anyway.
Additionally, it only makes sense on hot Flows/Observables. Decompose Value
is cold, so using ``collectAsStateWithLifecycle`` on it won't make any difference.John O'Reilly
11/12/2023, 12:55 PMArkadii Ivanov
11/12/2023, 12:58 PMcollectAsStateWithLifecycle
. I think this needs to be debugged with logs 🙂John O'Reilly
11/12/2023, 1:34 PMrepository.watchBookmarks
not being triggered in failing case (in SessionsComponent
)Arkadii Ivanov
11/12/2023, 1:52 PMadb shell am kill <pkg>
, then reopen the app.Arkadii Ivanov
11/12/2023, 1:53 PMJohn O'Reilly
11/12/2023, 1:53 PMJohn O'Reilly
11/12/2023, 1:53 PMArkadii Ivanov
11/12/2023, 1:54 PMJohn O'Reilly
11/12/2023, 5:45 PMArkadii Ivanov
11/12/2023, 5:51 PMJohn O'Reilly
11/12/2023, 5:53 PMJohn O'Reilly
11/12/2023, 5:54 PMJohn O'Reilly
11/12/2023, 5:55 PMonCompletion
for repository.watchBookmarks
and see that that being invoked.....perhaps a factorArkadii Ivanov
11/12/2023, 5:56 PMJohn O'Reilly
11/12/2023, 5:57 PMJohn O'Reilly
11/12/2023, 5:59 PM11-12 17:58:30.262 28746 28994 I FA : Application backgrounded at: timestamp_millis: 1699811908235
11-12 17:58:33.214 28746 28746 I System.out: JFOR, onCompletion
bring to foreground and then see issueJohn O'Reilly
11/12/2023, 5:59 PMJohn O'Reilly
11/12/2023, 6:04 PM11-12 18:04:10.756 29376 29376 I System.out: JFOR, onCompletion, it = kotlinx.coroutines.flow.internal.ChildCancelledException: Child of the scoped flow was cancelled
Arkadii Ivanov
11/12/2023, 6:04 PMJohn O'Reilly
11/12/2023, 6:05 PMrepository.watchBookmarks(conference, user?.uid, user, bookmarksData)
.map {
println("JFOR, watchBookmarks, it = ${it.data}, user = ${user?.uid}")
responseData.copy(bookmarksResponse = it)
}
.onStart {
println("JFOR, onStart")
emit(responseData)
}
.onCompletion {
println("JFOR, onCompletion, it = $it")
},
John O'Reilly
11/12/2023, 6:05 PMSessionsComponent
John O'Reilly
11/12/2023, 6:11 PMonCompletion
was somehow triggered that time as well......but it seems to be triggered consistently if app goes in to backgroundJohn O'Reilly
11/12/2023, 6:14 PMstateIn
here....
val uiState: StateFlow<SessionsUiState> =
combineUiState()
.combine(searchQuery) { uiState, search ->
filterSessions(uiState, search)
}.stateIn(coroutineScope, SharingStarted.WhileSubscribed(5000), SessionsUiState.Loading)
John O'Reilly
11/12/2023, 6:15 PMArkadii Ivanov
11/12/2023, 6:16 PMJohn O'Reilly
11/12/2023, 6:17 PMWhileSubscribed
to use say 20s then that's how long after going to background that I see onCompletion
logged..Arkadii Ivanov
11/12/2023, 6:21 PMArkadii Ivanov
11/12/2023, 6:21 PMArkadii Ivanov
11/12/2023, 6:29 PMArkadii Ivanov
11/12/2023, 6:39 PMJohn O'Reilly
11/12/2023, 6:40 PMJohn O'Reilly
11/12/2023, 6:41 PMChannel
was used there but seems like StateFlow
is cleaner approach all rightJohn O'Reilly
11/12/2023, 7:03 PMArkadii Ivanov
11/12/2023, 7:17 PMyschimke
11/12/2023, 9:12 PMmbonnin
11/12/2023, 10:40 PMmbonnin
11/12/2023, 10:45 PMChannel
stuff back in the day. I somewhat assumed this was called only once, sorryyschimke
11/13/2023, 4:01 AMyschimke
11/13/2023, 4:01 AMStylianos Gakis
11/13/2023, 8:01 AMChannel(Channel.UNLIMITED)
), wouldn’t it do the same as the MutableStateFlow here?
With the difference that it’d also not drop when more than 1 events comes in (which probably wouldn’t matter here anyway). And that StateFlow
just feels a bit out of place here no? Since we don’t really model state here, it’s just that we want the values to not be dropped.
But I could be wrong, wydt? 👀John O'Reilly
11/13/2023, 10:04 AMJohn O'Reilly
11/13/2023, 10:05 AMmbonnin
11/13/2023, 10:07 AMIf we use a channel with an unlimited buffer (I think the main difference is that), wouldn’t it do the same as the MutableStateFlow here?Channel(Channel.UNLIMITED)
channel.consumeAsFlow()
can be collected only once while you can collect a MutableStateFlow several times.Stylianos Gakis
11/13/2023, 10:07 AMchannel.receiveAsFlow()
which does not “consume” it, which again I think gives the same resultArkadii Ivanov
11/13/2023, 10:09 AMArkadii Ivanov
11/13/2023, 10:11 AMJohn O'Reilly
11/13/2023, 10:28 AMrepository.watchBookmarks
being cancelled but this is without app going in to background.....think it's somehow triggered by going between session list and bookmarks listJohn O'Reilly
11/13/2023, 10:30 AMbookmarksComponent
has dependency on sessionsComponent
but not sure if that could be a factorArkadii Ivanov
11/13/2023, 10:33 AMJohn O'Reilly
11/13/2023, 10:34 AMJohn O'Reilly
11/13/2023, 10:35 AMArkadii Ivanov
11/13/2023, 10:43 AMArkadii Ivanov
11/13/2023, 10:44 AMJohn O'Reilly
11/13/2023, 10:52 AMJohn O'Reilly
11/13/2023, 11:18 AMbookmarks
in BookmarksComponent
has dependency on SessionsComponent.uiState
....could there be any issue if SessionsComponent
has different lifecycle? Just thinking aloud right now 🙂Arkadii Ivanov
11/13/2023, 11:24 AMJohn O'Reilly
11/13/2023, 11:24 AMBookmarksComponent
creates it's own copy of SessionsComponent
John O'Reilly
11/13/2023, 11:25 AMArkadii Ivanov
11/13/2023, 11:27 AMBookmarksComponent
creates an instance of SessionsSimpleComponent
.Arkadii Ivanov
11/13/2023, 11:27 AMSessionsSimpleComponent
was extracted from SessionsComponent
so it can be reused.Arkadii Ivanov
11/13/2023, 11:28 AMJohn O'Reilly
11/13/2023, 12:38 PMfun watchBookmarks(
conference: String,
uid: String?,
tokenProvider: TokenProvider?,
initialData: GetBookmarksQuery.Data?,
): Flow<ApolloResponse<GetBookmarksQuery.Data>> = flow {
apolloClientCache.getClient(conference, uid).query(GetBookmarksQuery())
.tokenProvider(tokenProvider)
.watch(initialData)
emitAll(values)
}
instead of just
fun watchBookmarks(
conference: String,
uid: String?,
tokenProvider: TokenProvider?,
initialData: GetBookmarksQuery.Data?,
): Flow<ApolloResponse<GetBookmarksQuery.Data>> =
apolloClientCache.getClient(conference, uid).query(GetBookmarksQuery())
.tokenProvider(tokenProvider)
.watch(initialData)
mbonnin
11/13/2023, 12:39 PMJohn O'Reilly
11/13/2023, 12:44 PMbookmarkedSessionsQuery
(added I think for Wear client) might simplify logic we have for android client (for bookmarks view) as well (using a version of it with a watch
)John O'Reilly
11/13/2023, 6:50 PMrepository.watchBookmarks
in both places (session list and bookmark list) given both use session component......with one being cancelled as you switch to the other. And then for whatever reason it not being triggered when you make some change in one and switch to the other.Arkadii Ivanov
11/13/2023, 7:02 PMJohn O'Reilly
11/13/2023, 7:02 PMArkadii Ivanov
11/13/2023, 7:02 PMArkadii Ivanov
11/13/2023, 7:05 PMJohn O'Reilly
11/13/2023, 8:02 PMinitialData
in to watch
here?
fun watchBookmarks(
conference: String,
uid: String?,
tokenProvider: TokenProvider?,
initialData: GetBookmarksQuery.Data?,
): Flow<ApolloResponse<GetBookmarksQuery.Data>> = flow {
val values = apolloClientCache.getClient(conference, uid).query(GetBookmarksQuery())
.tokenProvider(tokenProvider)
.watch(initialData)
emitAll(values)
}
John O'Reilly
11/13/2023, 8:02 PMArkadii Ivanov
11/13/2023, 9:11 PMwatchBookmarks
doesn't emit the current set after subscription. So when you switch to the tab that was opened before (e.g. open bookmarks, change something there, then go back to session list), it emits the previously cached state (which I fixed yesterday), and then subscribes to watchBookmarks
and just waits for updates (which may not come).Arkadii Ivanov
11/13/2023, 9:27 PMArkadii Ivanov
11/13/2023, 9:30 PMmbonnin
11/13/2023, 9:54 PM@mbonnin what's purpose of passingThe initial set of keys to watch is retrieved fromin toinitialData
here?watch
initialData
. You can also pass null but the watcher will query the cache for every cache change until the query succeeds.John O'Reilly
11/14/2023, 7:33 AMJohn O'Reilly
11/14/2023, 1:15 PM