Update ImmutablePlugin associatedtype (#6)

This commit is contained in:
Zach 2023-02-08 17:07:42 -07:00 committed by GitHub
parent 9a84b81ac4
commit 415a13b088
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 5 deletions

View File

@ -1,26 +1,25 @@
/// A protocol that defines a plugin that can be registered and handled by a `Pluginable` object. /// A protocol that defines a plugin that can be registered and handled by a `Pluginable` object.
public protocol ImmutablePlugin: Plugin where Output == Void, Source == ImmutablePluginable { public protocol ImmutablePlugin: Plugin where Output == Void, Source == ImmutablePluginable {
/// The input value that the plugin will handle. associatedtype Input = Input
associatedtype Value
/// Handles the input value. /// Handles the input value.
/// ///
/// - Parameters: /// - Parameters:
/// - value: The input value that the plugin will handle. /// - value: The input value that the plugin will handle.
/// - Throws: Any errors that occur during handling of the input value. /// - Throws: Any errors that occur during handling of the input value.
func handle(value: Value) async throws func handle(value: Input) async throws
} }
// MARK: Public Implementation // MARK: Public Implementation
extension ImmutablePlugin where Value == Input { extension ImmutablePlugin {
/// A keypath that provides access to the `immutable` property of the `Source`. /// A keypath that provides access to the `immutable` property of the `Source`.
public var keyPath: WritableKeyPath<Source, ()> { public var keyPath: WritableKeyPath<Source, ()> {
get { \.immutable } get { \.immutable }
set { } set { }
} }
public func handle(value: Value, output: inout ()) async throws { public func handle(value: Input, output: inout ()) async throws {
try await handle(value: value) try await handle(value: value)
} }
} }