@@ -71,7 +71,7 @@ import SwiftUI
7171 ///
7272 /// It is okay to modify the state manually, instead of having it managed by a process like ``Processed/Loadable/Binding/load(silently:priority:block:)-4w49u``.
7373 /// However, doing so will cancel any ongoing task first, to prevent data races.
74- public var wrappedValue : LoadableState < Value > {
74+ @ MainActor public var wrappedValue : LoadableState < Value > {
7575 get { state }
7676 nonmutating set {
7777 cancel ( )
@@ -95,7 +95,7 @@ import SwiftUI
9595 /// try await fetchNumbers()
9696 /// }
9797 /// ```
98- public var projectedValue : Binding {
98+ @ MainActor public var projectedValue : Binding {
9999 . init( state: $state, task: $task)
100100 }
101101
@@ -210,10 +210,10 @@ extension Loadable {
210210 /// The block exposes a `yield` closure you can call to continuously update the resource loading state over time.
211211 ///
212212 /// - Returns: The task that runs the asynchronous loading process. You don't have to store it, but you can.
213- @discardableResult public func load(
213+ @MainActor @ discardableResult public func load(
214214 silently runSilently: Bool = false ,
215215 priority: TaskPriority ? = nil ,
216- block: @escaping ( _ yield: ( _ state: LoadableState < Value > ) -> Void ) async throws -> Void
216+ block: @MainActor @ escaping ( _ yield: ( _ state: LoadableState < Value > ) -> Void ) async throws -> Void
217217 ) -> Task < Void , Never > {
218218 cancel ( )
219219 setLoadingStateIfNeeded ( runSilently: runSilently)
@@ -253,9 +253,9 @@ extension Loadable {
253253 /// - runSilently: If `true`, the state will not be set to `.loading` initially.
254254 /// - block: The asynchronous block to run.
255255 /// The block exposes a `yield` closure you can call to continuously update the resource loading state over time.
256- public func load(
256+ @ MainActor public func load(
257257 silently runSilently: Bool = false ,
258- block: @escaping ( _ yield: ( _ state: LoadableState < Value > ) -> Void ) async throws -> Void
258+ block: @MainActor @ escaping ( _ yield: ( _ state: LoadableState < Value > ) -> Void ) async throws -> Void
259259 ) async {
260260 cancel ( )
261261 setLoadingStateIfNeeded ( runSilently: runSilently)
@@ -289,10 +289,10 @@ extension Loadable {
289289 /// - block: The asynchronous block to run.
290290 ///
291291 /// - Returns: The task that runs the asynchronous loading process. You don't have to store it, but you can.
292- @discardableResult public func load(
292+ @MainActor @ discardableResult public func load(
293293 silently runSilently: Bool = false ,
294294 priority: TaskPriority ? = nil ,
295- block: @escaping ( ) async throws -> Value
295+ block: @MainActor @ escaping ( ) async throws -> Value
296296 ) -> Task < Void , Never > {
297297 cancel ( )
298298 setLoadingStateIfNeeded ( runSilently: runSilently)
@@ -311,8 +311,8 @@ extension Loadable {
311311 self . task = task
312312 return task
313313 }
314-
315- /// Starts a resource loading process in the current asynchronous context,
314+
315+ /// Starts a resource loading process in the current asynchronous context,
316316 /// waiting for a return value or thrown error from the `block` closure,
317317 /// while setting the ``Processed/LoadableState`` accordingly.
318318 ///
@@ -327,9 +327,9 @@ extension Loadable {
327327 /// - Parameters:
328328 /// - runSilently: If `true`, the state will not be set to `.loading` initially.
329329 /// - block: The asynchronous block to run.
330- public func load(
330+ @ MainActor public func load(
331331 silently runSilently: Bool = false ,
332- block: @escaping ( ) async throws -> Value
332+ block: @MainActor @ escaping ( ) async throws -> Value
333333 ) async {
334334 cancel ( )
335335 setLoadingStateIfNeeded ( runSilently: runSilently)
0 commit comments