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 behaviors: [PageBehaviorProtocol]?
|
||||||
|
|
||||||
public var needsUpdateUI = false
|
public var needsUpdateUI = false
|
||||||
private var observingForResponses = false
|
private var observingForResponses: NSObjectProtocol?
|
||||||
private var initialLoadFinished = false
|
private var initialLoadFinished = false
|
||||||
public var previousScreenSize = CGSize.zero
|
public var previousScreenSize = CGSize.zero
|
||||||
|
|
||||||
@ -54,18 +54,21 @@ import MVMCore
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
open func observeForResponseJSONUpdates() {
|
open func observeForResponseJSONUpdates() {
|
||||||
guard !observingForResponses,
|
guard observingForResponses == nil,
|
||||||
(pagesToListenFor()?.count ?? 0 > 0 || modulesToListenFor()?.count ?? 0 > 0)
|
(pagesToListenFor()?.count ?? 0 > 0 || modulesToListenFor()?.count ?? 0 > 0)
|
||||||
else { return }
|
else { return }
|
||||||
|
|
||||||
observingForResponses = true
|
let pageUpdateQueue = OperationQueue()
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(responseJSONUpdated(notification:)), name: NSNotification.Name(rawValue: NotificationResponseLoaded), object: nil)
|
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() {
|
open func stopObservingForResponseJSONUpdates() {
|
||||||
guard observingForResponses else { return }
|
guard let observingForResponses = observingForResponses else { return }
|
||||||
NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NotificationResponseLoaded), object: nil)
|
NotificationCenter.default.removeObserver(observingForResponses)
|
||||||
observingForResponses = false
|
self.observingForResponses = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
open func pagesToListenFor() -> [String]? {
|
open func pagesToListenFor() -> [String]? {
|
||||||
|
|||||||
@ -76,7 +76,7 @@ public class AddRemoveMoleculesBehavior: PageCustomActionHandlerBehavior, PageMo
|
|||||||
self.delegate = delegateObject
|
self.delegate = delegateObject
|
||||||
}
|
}
|
||||||
|
|
||||||
public func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject?) {
|
public func willRender(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject?) {
|
||||||
guard let list = delegate?.moleculeListDelegate else { return }
|
guard let list = delegate?.moleculeListDelegate else { return }
|
||||||
for case let model as (MoleculeModelProtocol & ListItemModelProtocol & AddMolecules) in rootMolecules {
|
for case let model as (MoleculeModelProtocol & ListItemModelProtocol & AddMolecules) in rootMolecules {
|
||||||
if let moleculesToAdd = model.getRecursiveMoleculesToAdd(),
|
if let moleculesToAdd = model.getRecursiveMoleculesToAdd(),
|
||||||
|
|||||||
@ -35,6 +35,7 @@ public protocol PageMoleculeTransformationBehavior: PageBehaviorProtocol {
|
|||||||
func didSetupMolecule(view: MoleculeViewProtocol, withModel: MoleculeModelProtocol)
|
func didSetupMolecule(view: MoleculeViewProtocol, withModel: MoleculeModelProtocol)
|
||||||
func willSetupNavigationBar(with model: NavigationItemModelProtocol, updating view: UINavigationBar)
|
func willSetupNavigationBar(with model: NavigationItemModelProtocol, updating view: UINavigationBar)
|
||||||
func didSetupNavigationBar(view: UINavigationBar, with model: NavigationItemModelProtocol)
|
func didSetupNavigationBar(view: UINavigationBar, with model: NavigationItemModelProtocol)
|
||||||
|
func willRender(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject?)
|
||||||
func shouldFinishProcessingLoad(_ loadObject: MVMCoreLoadObject) throws -> Bool
|
func shouldFinishProcessingLoad(_ loadObject: MVMCoreLoadObject) throws -> Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,6 +46,7 @@ public extension PageMoleculeTransformationBehavior {
|
|||||||
func didSetupMolecule(view: MoleculeViewProtocol, withModel: MoleculeModelProtocol) {}
|
func didSetupMolecule(view: MoleculeViewProtocol, withModel: MoleculeModelProtocol) {}
|
||||||
func willSetupNavigationBar(with model: NavigationItemModelProtocol, updating view: UINavigationBar) {}
|
func willSetupNavigationBar(with model: NavigationItemModelProtocol, updating view: UINavigationBar) {}
|
||||||
func didSetupNavigationBar(view: UINavigationBar, with model: NavigationItemModelProtocol) {}
|
func didSetupNavigationBar(view: UINavigationBar, with model: NavigationItemModelProtocol) {}
|
||||||
|
func willRender(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject?) {}
|
||||||
func shouldFinishProcessingLoad(_ loadObject: MVMCoreLoadObject) throws -> Bool { return true }
|
func shouldFinishProcessingLoad(_ loadObject: MVMCoreLoadObject) throws -> Bool { return true }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user