Skip to content

Commit

Permalink
Make viewStorage lazy
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmeichigo committed Nov 27, 2024
1 parent 37bcfc7 commit bbdb9ea
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Storage/Storage/CoreData/CoreDataManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ public final class CoreDataManager: StorageManagerType {

/// Returns the Storage associated with the View Thread.
///
public var viewStorage: StorageType {
public lazy var viewStorage: StorageType = {
let context = persistentContainer.viewContext
/// This simplifies the process of merging updates from persistent container to view context.
/// When disable auto merge, we need to handle merging manually using `NSManagedObjectContextDidSave` notifications.
context.automaticallyMergesChangesFromParent = true
context.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy
return context
}
}()

/// Returns a shared derived storage instance dedicated for write operations.
///
Expand Down

0 comments on commit bbdb9ea

Please sign in to comment.