Skip to content

Commit

Permalink
Use fewer default types
Browse files Browse the repository at this point in the history
  • Loading branch information
g-mark committed Jun 26, 2024
1 parent f0caa8d commit dfa136d
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions Sources/Lasso/Module.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ public protocol StoreModule {
associatedtype Output

/// The primary, type-erased, public access `Store` for the module.
typealias Store = AnyStore<State, Action, Output>
typealias Store = AnyStore<Self.State, Self.Action, Self.Output>

/// 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<State, Action>
typealias ViewStore = AnyViewStore<Self.State, Self.Action>

}

Expand All @@ -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<Self>

Expand Down Expand Up @@ -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<ViewState, ViewAction>
typealias ViewStore = AnyViewStore<Self.ViewState, Self.ViewAction>
}

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.
Expand Down

0 comments on commit dfa136d

Please sign in to comment.