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