Add will render event to avoid circumvent addRemoveListItemBehavior conflict. Page concurrent update sequentialization.
This commit is contained in:
parent
33a05b79a6
commit
1cb490f822
@ -38,7 +38,7 @@ import MVMCore
|
||||
public var behaviors: [PageBehaviorProtocol]?
|
||||
|
||||
public var needsUpdateUI = false
|
||||
private var observingForResponses = false
|
||||
private var observingForResponses: NSObjectProtocol?
|
||||
private var initialLoadFinished = false
|
||||
public var previousScreenSize = CGSize.zero
|
||||
|
||||
@ -54,18 +54,21 @@ import MVMCore
|
||||
//--------------------------------------------------
|
||||
|
||||
open func observeForResponseJSONUpdates() {
|
||||
guard !observingForResponses,
|
||||
guard observingForResponses == nil,
|
||||
(pagesToListenFor()?.count ?? 0 > 0 || modulesToListenFor()?.count ?? 0 > 0)
|
||||
else { return }
|
||||
|
||||
observingForResponses = true
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(responseJSONUpdated(notification:)), name: NSNotification.Name(rawValue: NotificationResponseLoaded), object: nil)
|
||||
let pageUpdateQueue = OperationQueue()
|
||||
pageUpdateQueue.maxConcurrentOperationCount = 1
|
||||
pageUpdateQueue.qualityOfService = .userInteractive
|
||||
|
||||
observingForResponses = NotificationCenter.default.addObserver(forName: NSNotification.Name(rawValue: NotificationResponseLoaded), object: nil, queue: pageUpdateQueue, using: responseJSONUpdated(notification:))
|
||||
}
|
||||
|
||||
open func stopObservingForResponseJSONUpdates() {
|
||||
guard observingForResponses else { return }
|
||||
NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NotificationResponseLoaded), object: nil)
|
||||
observingForResponses = false
|
||||
guard let observingForResponses = observingForResponses else { return }
|
||||
NotificationCenter.default.removeObserver(observingForResponses)
|
||||
self.observingForResponses = nil
|
||||
}
|
||||
|
||||
open func pagesToListenFor() -> [String]? {
|
||||
|
||||
@ -76,7 +76,7 @@ public class AddRemoveMoleculesBehavior: PageCustomActionHandlerBehavior, PageMo
|
||||
self.delegate = delegateObject
|
||||
}
|
||||
|
||||
public func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject?) {
|
||||
public func willRender(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject?) {
|
||||
guard let list = delegate?.moleculeListDelegate else { return }
|
||||
for case let model as (MoleculeModelProtocol & ListItemModelProtocol & AddMolecules) in rootMolecules {
|
||||
if let moleculesToAdd = model.getRecursiveMoleculesToAdd(),
|
||||
|
||||
@ -35,6 +35,7 @@ public protocol PageMoleculeTransformationBehavior: PageBehaviorProtocol {
|
||||
func didSetupMolecule(view: MoleculeViewProtocol, withModel: MoleculeModelProtocol)
|
||||
func willSetupNavigationBar(with model: NavigationItemModelProtocol, updating view: UINavigationBar)
|
||||
func didSetupNavigationBar(view: UINavigationBar, with model: NavigationItemModelProtocol)
|
||||
func willRender(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject?)
|
||||
func shouldFinishProcessingLoad(_ loadObject: MVMCoreLoadObject) throws -> Bool
|
||||
}
|
||||
|
||||
@ -45,6 +46,7 @@ public extension PageMoleculeTransformationBehavior {
|
||||
func didSetupMolecule(view: MoleculeViewProtocol, withModel: MoleculeModelProtocol) {}
|
||||
func willSetupNavigationBar(with model: NavigationItemModelProtocol, updating view: UINavigationBar) {}
|
||||
func didSetupNavigationBar(view: UINavigationBar, with model: NavigationItemModelProtocol) {}
|
||||
func willRender(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject?) {}
|
||||
func shouldFinishProcessingLoad(_ loadObject: MVMCoreLoadObject) throws -> Bool { return true }
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user