Merge branch 'develop' into feature/childrenForlistLVCBBdy
This commit is contained in:
commit
cece765660
@ -146,6 +146,19 @@ import MVMCore
|
||||
}
|
||||
}
|
||||
|
||||
///Check with behavior if it can continue
|
||||
do{
|
||||
let allFinishedProcessingLoad = try executeThrowingBehaviors {(behavior: PageMoleculeTransformationBehavior) in
|
||||
return try behavior.shouldFinishProcessingLoad(loadObject)
|
||||
}
|
||||
guard allFinishedProcessingLoad else { return false }
|
||||
} catch let behaviorError {
|
||||
if let errorObject = MVMCoreErrorObject.createErrorObject(for: behaviorError, location: MVMCoreLoadHandler.sharedGlobal()?.errorLocation(forRequest: loadObject)) {
|
||||
error.pointee = errorObject
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@ -44,4 +44,8 @@ public extension PageBehaviorHandlerProtocol {
|
||||
func executeBehaviors<T>(_ behaviorBlock: (_ behavior: T) -> Void) {
|
||||
behaviors?.compactMap { $0 as? T }.forEach { behaviorBlock($0) }
|
||||
}
|
||||
|
||||
func executeThrowingBehaviors<T>(_ behaviourBlock: (_ behavior: T) throws -> Bool) throws -> Bool {
|
||||
return try behaviors?.compactMap({$0 as? T}).allSatisfy({ return try behaviourBlock($0) }) ?? true
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,6 +32,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 shouldFinishProcessingLoad(_ loadObject: MVMCoreLoadObject) throws -> Bool
|
||||
}
|
||||
|
||||
public extension PageMoleculeTransformationBehavior {
|
||||
@ -41,6 +42,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 shouldFinishProcessingLoad(_ loadObject: MVMCoreLoadObject) throws -> Bool { return true }
|
||||
}
|
||||
|
||||
public protocol PageVisibilityBehavior: PageBehaviorProtocol {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user