From dfa136dff66040c3f5d9dcbe059e37fbfdbb12a7 Mon Sep 17 00:00:00 2001 From: Steven Grosmark Date: Wed, 26 Jun 2024 08:55:31 -0400 Subject: [PATCH] Use fewer default types --- Sources/Lasso/Module.swift | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/Sources/Lasso/Module.swift b/Sources/Lasso/Module.swift index 9db2faf..0e0a3f7 100644 --- a/Sources/Lasso/Module.swift +++ b/Sources/Lasso/Module.swift @@ -37,11 +37,11 @@ public protocol StoreModule { associatedtype Output /// The primary, type-erased, public access `Store` for the module. - typealias Store = AnyStore + typealias Store = AnyStore /// The `ViewStore` is a type-erased lens into the `Store`, that hides the `Output`. /// The `ViewStore` is typically used as the interface the view controller sees. - typealias ViewStore = AnyViewStore + typealias ViewStore = AnyViewStore } @@ -61,7 +61,10 @@ extension StoreModule { /// be instantiated and 'hooked into' the controlling `Store`. public protocol ScreenModule: StoreModule { - associatedtype ConcreteStore: Lasso.ConcreteStore where ConcreteStore.State == State, ConcreteStore.Action == Action, ConcreteStore.Output == Output + associatedtype ConcreteStore: Lasso.ConcreteStore + where ConcreteStore.State == Self.State, + ConcreteStore.Action == Self.Action, + ConcreteStore.Output == Self.Output typealias Screen = AnyScreen @@ -105,20 +108,28 @@ extension ScreenModule where State == EmptyState { /// of testable business logic. In this fashion, it is possible to extract all business logic from the view layer. public protocol ViewModule { - associatedtype ViewAction = NoAction - associatedtype ViewState = EmptyState + associatedtype ViewAction + associatedtype ViewState - typealias ViewStore = AnyViewStore + typealias ViewStore = AnyViewStore +} + +extension ViewModule { + public typealias ViewAction = NoAction + public typealias ViewState = EmptyState } /// A FlowModule describes the types that can be used in a flow. /// FlowModules have Output, and can specify what kind of view controller they are placed in. public protocol FlowModule { - associatedtype Output = NoOutput + associatedtype Output associatedtype RequiredContext: UIViewController = UIViewController - +} + +extension FlowModule { + public typealias Output = NoOutput } /// A FlowModule where the RequiredContext is bound to a UINavigationController.