Skip to content

Commit

Permalink
Merge pull request #346 from tangem/IOS-5193_add_convenience_method
Browse files Browse the repository at this point in the history
IOS-5193 Add convenience method
  • Loading branch information
tureck1y authored Apr 15, 2024
2 parents 151522d + 5a77a2f commit b2b15a4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions TangemSdk/TangemSdk/Common/Extensions/TangemSdk+Combine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,20 @@ extension TangemSdk {
self.startSession(with: runnable, cardId: cardId, initialMessage: initialMessage, accessCode: accessCode, completion: $0)
}}.eraseToAnyPublisher()
}

/// Combine wrapper for `startSession` method.
/// - Parameters:
/// - runnable: A custom task, adopting `CardSessionRunnable` protocol
/// - filter: Filters card to be read. Optional.
/// - initialMessage: A custom description that shows at the beginning of the NFC session. If nil, default message will be used
/// - accessCode: Access code that will be used for a card session initialization. If nil, Tangem SDK will handle it automatically.
/// - Returns: `AnyPublisher<T.Response, TangemSdkError>`
public func startSessionPublisher<T: CardSessionRunnable>(with runnable: T,
filter: SessionFilter?,
initialMessage: Message? = nil,
accessCode: String? = nil) -> AnyPublisher<T.Response, TangemSdkError> {
return Deferred { Future() {
self.startSession(with: runnable, filter: filter, initialMessage: initialMessage, accessCode: accessCode, completion: $0)
}}.eraseToAnyPublisher()
}
}

0 comments on commit b2b15a4

Please sign in to comment.