Skip to content

Commit c371d98

Browse files
authored
Refactoring (#52)
1 parent c838d36 commit c371d98

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

Examples/Packages/iOS/Sources/ExampleMovieDB/Screens/MoviesScreen.swift

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ struct MoviesScreen: View {
88
@WatchState(SearchQueryAtom())
99
var searchQuery
1010

11-
@ViewContext
12-
var context
13-
1411
@State
1512
var isShowingSearchScreen = false
1613

@@ -45,9 +42,12 @@ struct MoviesScreen: View {
4542
}
4643

4744
if let last = pages.last, last.hasNextPage {
48-
ProgressRow().task {
49-
await loader.loadNext()
50-
}
45+
ProgressRow()
46+
// NB: Since ProgressView placed in the List will not redisplay its indicator once it's hidden, here adds a random ID so that it's always regenerated.
47+
.id(UUID())
48+
.task {
49+
await loader.loadNext()
50+
}
5151
}
5252
}
5353
}
@@ -70,10 +70,7 @@ struct MoviesScreen: View {
7070
await loader.refresh()
7171
}
7272
.refreshable {
73-
// NB: Implicitly capturing `self` causes memory leak with `refreshable`,
74-
// and also capturing `loader` makes refresh doesn't work, so here reads
75-
// `MovieLoader` via context.
76-
await context.read(MovieLoaderAtom()).refresh()
73+
await loader.refresh()
7774
}
7875
.background {
7976
NavigationLink(

0 commit comments

Comments
 (0)