Skip to content

Commit

Permalink
Avoid MainActor.assumeIsolated
Browse files Browse the repository at this point in the history
  • Loading branch information
hallee committed Jun 23, 2024
1 parent 21cf3f0 commit 2d264ea
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions Sources/PulseUI/Features/Console/ConsoleDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ protocol ConsoleDataSourceDelegate: AnyObject {
func dataSource(_ dataSource: ConsoleDataSource, didUpdateWith diff: CollectionDifference<NSManagedObjectID>?)
}

@MainActor
final class ConsoleDataSource: NSObject, NSFetchedResultsControllerDelegate {
weak var delegate: ConsoleDataSourceDelegate?

Expand Down Expand Up @@ -103,7 +102,7 @@ final class ConsoleDataSource: NSObject, NSFetchedResultsControllerDelegate {
controller.delegate = controllerDelegate
}

func bind(_ filters: ConsoleFiltersViewModel) {
@MainActor func bind(_ filters: ConsoleFiltersViewModel) {
cancellables = []
filters.$options.sink { [weak self] in
self?.predicate = $0
Expand Down Expand Up @@ -135,16 +134,12 @@ final class ConsoleDataSource: NSObject, NSFetchedResultsControllerDelegate {

// MARK: NSFetchedResultsControllerDelegate

nonisolated func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
MainActor.assumeIsolated {
delegate?.dataSource(self, didUpdateWith: nil)
}
func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
delegate?.dataSource(self, didUpdateWith: nil)
}

nonisolated func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChangeContentWith diff: CollectionDifference<NSManagedObjectID>) {
MainActor.assumeIsolated {
delegate?.dataSource(self, didUpdateWith: diff)
}
func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChangeContentWith diff: CollectionDifference<NSManagedObjectID>) {
delegate?.dataSource(self, didUpdateWith: diff)
}

// MARK: Predicate
Expand Down

0 comments on commit 2d264ea

Please sign in to comment.