From 6762082b7c24e248b5c2922bde7d8fd4e0f27715 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 2 May 2022 17:52:15 -0400 Subject: [PATCH] move function behavior for scoping --- .../Behaviors/Protocols/PageBehaviorHandlerProtocol.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift b/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift index eb244cbf..cdabba87 100644 --- a/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift +++ b/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift @@ -34,4 +34,9 @@ public extension PageBehaviorHandlerProtocol { } self.behaviors = behaviors.count > 0 ? behaviors : nil } + + /// Executes all behaviors of type. + public func executeBehaviors(_ behaviorBlock: (_ behavior: T) -> Void) { + behaviors?.compactMap { $0 as? T }.forEach { behaviorBlock($0) } + } }