Merge branch 'feature/hab_enhancements' into 'develop'

behavior transcendence

See merge request BPHV_MIPS/mvm_core_ui!882
This commit is contained in:
Pfeil, Scott Robert 2022-07-15 16:35:27 +00:00
commit c3db764db7
3 changed files with 15 additions and 3 deletions

View File

@ -42,7 +42,7 @@ public extension TemplateProtocol {
behaviorHandlerModel.traverseAndAddRequiredBehaviors()
behaviorHandler.createBehaviors(for: behaviorHandlerModel, delegateObject: delegateObject)
if let viewController = self as? UIViewController {
MVMCoreUISession.sharedGlobal()?.applyGlobalBehaviors(to: (viewController))
MVMCoreUISession.sharedGlobal()?.applyGlobalBehaviors(to: viewController)
}
}

View File

@ -14,12 +14,17 @@ public protocol PageBehaviorHandlerProtocol {
public extension PageBehaviorHandlerProtocol {
/// Creates the behaviors and sets the variable.
mutating func createBehaviors(for model: PageBehaviorHandlerModelProtocol, delegateObject: MVMCoreUIDelegateObject?) {
guard let behaviorModels = model.behaviors else {
behaviors = behaviors?.filter { $0.transcendsPageUpdates }
if behaviors?.isEmpty ?? false {
behaviors = nil
}
guard let behaviorModels = model.behaviors else {
return
}
var behaviors: [PageBehaviorProtocol] = []
var behaviors: [PageBehaviorProtocol] = behaviors ?? []
for behaviorModel in behaviorModels {
do {

View File

@ -9,10 +9,17 @@
public protocol PageBehaviorProtocol: ModelHandlerProtocol {
/// Should the behavior persist regardless of page behavior model updates.
var transcendsPageUpdates: Bool { get }
/// Initializes the behavior with the model
init(model: PageBehaviorModelProtocol, delegateObject: MVMCoreUIDelegateObject?)
}
public extension PageBehaviorProtocol {
var transcendsPageUpdates: Bool { return false }
}
/**
Behavior conforming protocols. Behaviors will conform to one or more of these protocols to receive page lifecycle events that pertain to them.
*/