Making the shouldFinishProcessingLoad method in behavior to throw
This commit is contained in:
parent
904cdf3798
commit
29c73f2ccc
@ -146,15 +146,20 @@ import MVMCore
|
||||
}
|
||||
}
|
||||
|
||||
///Check with behavior if it can continue
|
||||
let conditionSatisfied = conditionSatisfyingBehaviours { (behavior: PageMoleculeTransformationBehavior) in
|
||||
return behavior.shouldFinishProcessingLoad(loadObject)
|
||||
///Check with behavior if it can continue
|
||||
do{
|
||||
let conditionSatisfied = try executeThrowingBehaviors {(behavior: PageMoleculeTransformationBehavior) in
|
||||
return try behavior.shouldFinishProcessingLoad(loadObject)
|
||||
}
|
||||
if conditionSatisfied == false {
|
||||
return conditionSatisfied
|
||||
}
|
||||
} catch let behaviorError {
|
||||
if let errorObject = MVMCoreErrorObject.createErrorObject(for: behaviorError, location: MVMCoreLoadHandler.sharedGlobal()?.errorLocation(forRequest: loadObject)) {
|
||||
error.pointee = errorObject
|
||||
}
|
||||
}
|
||||
|
||||
if conditionSatisfied == false {
|
||||
return conditionSatisfied
|
||||
}
|
||||
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ public extension PageBehaviorHandlerProtocol {
|
||||
behaviors?.compactMap { $0 as? T }.forEach { behaviorBlock($0) }
|
||||
}
|
||||
|
||||
func conditionSatisfyingBehaviours<T>(_ behaviourBlock: (_ behavior: T) -> Bool) -> Bool {
|
||||
return behaviors?.compactMap({$0 as? T}).allSatisfy({ return behaviourBlock($0) }) ?? false
|
||||
func executeThrowingBehaviors<T>(_ behaviourBlock: (_ behavior: T) throws -> Bool) throws -> Bool {
|
||||
return try behaviors?.compactMap({$0 as? T}).allSatisfy({ return try behaviourBlock($0) }) ?? false
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,7 +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) -> Bool
|
||||
func shouldFinishProcessingLoad(_ loadObject: MVMCoreLoadObject) throws -> Bool
|
||||
}
|
||||
|
||||
public extension PageMoleculeTransformationBehavior {
|
||||
@ -42,7 +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) -> Bool { return true }
|
||||
func shouldFinishProcessingLoad(_ loadObject: MVMCoreLoadObject) throws -> Bool { return true }
|
||||
}
|
||||
|
||||
public protocol PageVisibilityBehavior: PageBehaviorProtocol {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user