convenience functions

This commit is contained in:
Scott Pfeil 2022-05-02 17:54:37 -04:00
parent 6762082b7c
commit 677c352b9e
2 changed files with 5 additions and 2 deletions

View File

@ -36,7 +36,7 @@ public extension PageBehaviorHandlerProtocol {
} }
/// Executes all behaviors of type. /// Executes all behaviors of type.
public func executeBehaviors<T>(_ behaviorBlock: (_ behavior: T) -> Void) { func executeBehaviors<T>(_ behaviorBlock: (_ behavior: T) -> Void) {
behaviors?.compactMap { $0 as? T }.forEach { behaviorBlock($0) } behaviors?.compactMap { $0 as? T }.forEach { behaviorBlock($0) }
} }
} }

View File

@ -50,8 +50,11 @@ public protocol PageCustomActionHandlerBehavior: PageBehaviorProtocol {
} }
public extension MVMCoreUIDelegateObject { public extension MVMCoreUIDelegateObject {
var behaviorModelDelegate: PageBehaviorHandlerModelProtocol? {
(moleculeDelegate as? PageProtocol)?.pageModel as? PageBehaviorHandlerModelProtocol
}
weak var behaviorTemplateDelegate: (PageBehaviorHandlerProtocol & NSObjectProtocol)? { weak var behaviorTemplateDelegate: (PageBehaviorHandlerProtocol & NSObjectProtocol)? {
(moleculeDelegate as? PageProtocol)?.pageModel as? (PageBehaviorHandlerProtocol & NSObjectProtocol) moleculeDelegate as? (PageBehaviorHandlerProtocol & NSObjectProtocol)
} }
} }