push model in action events for model specfic attributes
This commit is contained in:
parent
e5402bb6eb
commit
a5d237df8b
@ -97,14 +97,14 @@ public protocol MVMCoreJSONActionHandlerProtocol: MVMCoreActionHandlerProtocol {
|
|||||||
do {
|
do {
|
||||||
let handlerType = try ModelRegistry.getHandler(model) as! MVMCoreActionHandlerProtocol.Type
|
let handlerType = try ModelRegistry.getHandler(model) as! MVMCoreActionHandlerProtocol.Type
|
||||||
let handler = handlerType.init()
|
let handler = handlerType.init()
|
||||||
MVMCoreLoggingHandler.shared()?.logCoreEvent(.actionInvoked(name: model.actionType, pageType: pageType(from: delegateObject), uuid: uuid))
|
MVMCoreLoggingHandler.shared()?.logCoreEvent(.actionInvoked(name: model.actionType, pageType: pageType(from: delegateObject), uuid: uuid, model: model))
|
||||||
if let handler = handler as? MVMCoreJSONActionHandlerProtocol {
|
if let handler = handler as? MVMCoreJSONActionHandlerProtocol {
|
||||||
// Needed until we can remove legacy delegate functions.
|
// Needed until we can remove legacy delegate functions.
|
||||||
try await handler.performAction(with: json, model: model, delegateObject: delegateObject, additionalData: additionalData)
|
try await handler.performAction(with: json, model: model, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
} else {
|
} else {
|
||||||
try await handler.execute(with: model, delegateObject: delegateObject, additionalData: additionalData)
|
try await handler.execute(with: model, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
}
|
}
|
||||||
MVMCoreLoggingHandler.shared()?.logCoreEvent(.actionComplete(name: model.actionType, pageType: pageType(from: delegateObject), uuid: uuid))
|
MVMCoreLoggingHandler.shared()?.logCoreEvent(.actionComplete(name: model.actionType, pageType: pageType(from: delegateObject), uuid: uuid, model: model))
|
||||||
} catch ModelRegistry.Error.handlerNotMapped {
|
} catch ModelRegistry.Error.handlerNotMapped {
|
||||||
try Task.checkCancellation()
|
try Task.checkCancellation()
|
||||||
// Allows custom handling if there no handler for the action.
|
// Allows custom handling if there no handler for the action.
|
||||||
@ -114,7 +114,7 @@ public protocol MVMCoreJSONActionHandlerProtocol: MVMCoreActionHandlerProtocol {
|
|||||||
throw ActionError.unknownAction(type: model.actionType)
|
throw ActionError.unknownAction(type: model.actionType)
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
MVMCoreLoggingHandler.shared()?.logCoreEvent(.actionFailed(name: model.actionType, pageType: pageType(from: delegateObject), uuid: uuid, error: error))
|
MVMCoreLoggingHandler.shared()?.logCoreEvent(.actionFailed(name: model.actionType, pageType: pageType(from: delegateObject), uuid: uuid, model: model, error: error))
|
||||||
MVMCoreActionHandler.log(string: "Failed Action \(error)", additionalData: additionalData)
|
MVMCoreActionHandler.log(string: "Failed Action \(error)", additionalData: additionalData)
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,26 +29,29 @@ public enum MVMCoreEvent {
|
|||||||
pageType: String
|
pageType: String
|
||||||
)
|
)
|
||||||
|
|
||||||
/// The webview bridge action handler was invoked and is in progress.
|
/// The core action handler was invoked and is in progress.
|
||||||
case actionInvoked(
|
case actionInvoked(
|
||||||
name: String,
|
name: String,
|
||||||
pageType: String,
|
pageType: String,
|
||||||
uuid: String
|
uuid: String,
|
||||||
|
model: ActionModelProtocol
|
||||||
)
|
)
|
||||||
|
|
||||||
/// The action failed..
|
/// The core action handler fail to complete the action.
|
||||||
case actionFailed(
|
case actionFailed(
|
||||||
name: String,
|
name: String,
|
||||||
pageType: String,
|
pageType: String,
|
||||||
uuid: String,
|
uuid: String,
|
||||||
|
model: ActionModelProtocol,
|
||||||
error: Error?
|
error: Error?
|
||||||
)
|
)
|
||||||
|
|
||||||
/// The action is completed.
|
/// The core action handler completed an action.
|
||||||
case actionComplete(
|
case actionComplete(
|
||||||
name: String,
|
name: String,
|
||||||
pageType: String,
|
pageType: String,
|
||||||
uuid: String
|
uuid: String,
|
||||||
|
model: ActionModelProtocol
|
||||||
)
|
)
|
||||||
|
|
||||||
// ----------------------------
|
// ----------------------------
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user