callAsFunction
値に callAsFunction という関数があると、値を関数のように呼び出すことができるSwiftの機能
code:call_as_function.swift
struct FooBarUseCase {
let fooRepository: FooRepositoryProtocol
func callAsFunction(_ id: string) {
fooRepository.ping(id)
}
}
let useCase = FooBarUseCase(fooRepository: FooRepository())
useCase(10)
https://github.com/apple/swift-evolution/blob/master/proposals/0253-callable.md
cockscombさんがSwiftUIにおけるActionパターンとしてブログに書いている。