Skip to content

Commit 3ecb776

Browse files
authoredJul 22, 2023
Update from load on main thread (#7)
1 parent 1217e37 commit 3ecb776

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed
 

‎Sources/DataStore/DataStore.swift

+7-3
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,9 @@ where StoredData.From == DataLoader.DeviceData,
149149
open func load() async throws {
150150
let loadedData: [DeviceData] = try await loader.load()
151151

152-
try store(data: loadedData)
152+
try await MainActor.run {
153+
try store(data: loadedData)
154+
}
153155
}
154156

155157
/**
@@ -164,8 +166,10 @@ where StoredData.From == DataLoader.DeviceData,
164166
*/
165167
open func load(id: LoadedData.ID) async throws {
166168
let loadedData: DeviceData = try await loader.load(id: id)
167-
168-
try store(data: [loadedData])
169+
170+
try await MainActor.run {
171+
try store(data: [loadedData])
172+
}
169173
}
170174
}
171175

0 commit comments

Comments
 (0)
Please sign in to comment.