Introducing shouldFinishProcessingLoad call to behavior to check if we can continue to load the viewcontroller
This commit is contained in:
parent
081dbbf65e
commit
904cdf3798
@ -146,6 +146,15 @@ import MVMCore
|
||||
}
|
||||
}
|
||||
|
||||
///Check with behavior if it can continue
|
||||
let conditionSatisfied = conditionSatisfyingBehaviours { (behavior: PageMoleculeTransformationBehavior) in
|
||||
return behavior.shouldFinishProcessingLoad(loadObject)
|
||||
}
|
||||
|
||||
if conditionSatisfied == false {
|
||||
return conditionSatisfied
|
||||
}
|
||||
|
||||
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 conditionSatisfyingBehaviours<T>(_ behaviourBlock: (_ behavior: T) -> Bool) -> Bool {
|
||||
return behaviors?.compactMap({$0 as? T}).allSatisfy({ return behaviourBlock($0) }) ?? false
|
||||
}
|
||||
}
|
||||
|
||||
@ -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) -> 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) -> Bool { return true }
|
||||
}
|
||||
|
||||
public protocol PageVisibilityBehavior: PageBehaviorProtocol {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user