diff --git a/mvvm-flow/apple/xcode/mokoMvvmFlowSwiftUI/ViewModelState.swift b/mvvm-flow/apple/xcode/mokoMvvmFlowSwiftUI/ViewModelState.swift index 358adf7..00f9d4b 100644 --- a/mvvm-flow/apple/xcode/mokoMvvmFlowSwiftUI/ViewModelState.swift +++ b/mvvm-flow/apple/xcode/mokoMvvmFlowSwiftUI/ViewModelState.swift @@ -93,4 +93,12 @@ public extension ObservableObject where Self: ViewModel { mapper: { $0 as! Array } ) } + + func state(_ flowKey: KeyPath>) -> T { + return state( + flowKey, + equals: { $0.isEqual($1) }, + mapper: { $0 } + ) + } } diff --git a/mvvm-flow/apple/xcode/mokoMvvmFlowSwiftUI/ViewModelStateNullable.swift b/mvvm-flow/apple/xcode/mokoMvvmFlowSwiftUI/ViewModelStateNullable.swift index ed49ce3..b0fbdf4 100644 --- a/mvvm-flow/apple/xcode/mokoMvvmFlowSwiftUI/ViewModelStateNullable.swift +++ b/mvvm-flow/apple/xcode/mokoMvvmFlowSwiftUI/ViewModelStateNullable.swift @@ -103,4 +103,12 @@ extension ObservableObject where Self: ViewModel { mapper: { $0?.localized() } ) } + + func stateNullable(_ flowKey: KeyPath>) -> T? { + return stateNullable( + flowKey, + equals: { $0?.isEqual($1) == true }, + mapper: { $0 } + ) + } }