mirror of
https://github.com/bitwarden/ios.git
synced 2025-12-13 11:03:35 -06:00
31 lines
876 B
Swift
31 lines
876 B
Swift
import Combine
|
|
import Foundation
|
|
|
|
/// A processor is responsible for receiving and processing dispatched actions. Generally a
|
|
/// processor will mutate local state based on the action it receives.
|
|
///
|
|
@MainActor
|
|
public protocol Processor: AnyObject, Sendable {
|
|
associatedtype State: Sendable
|
|
associatedtype Action: Sendable
|
|
associatedtype Effect: Sendable
|
|
|
|
/// The processor's current state.
|
|
var state: State { get }
|
|
|
|
/// A publisher that publishes the processor's state when it changes.
|
|
var statePublisher: AnyPublisher<State, Never> { get }
|
|
|
|
/// Performs an asynchronous effect.
|
|
///
|
|
/// - Parameter effect: The effect to perform.
|
|
///
|
|
func perform(_ effect: Effect) async
|
|
|
|
/// Receives an action from the view's store.
|
|
///
|
|
/// - Parameter action: The action to process.
|
|
///
|
|
func receive(_ action: Action)
|
|
}
|