Skip to content

Commit

Permalink
Clarify and expand on the role of TokenProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmassicotte committed Nov 25, 2024
1 parent cbde4e3 commit 6b83e57
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Sources/Neon/Token.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ public struct TokenApplication: Hashable, Sendable {
public static let noChange = TokenApplication(tokens: [], action: .apply)
}

/// A type that assigns semantic value to a range of text either syncrhonously or asychrnoously.
/// A type that assigns semantic value to a range of text either synchronously or asynchronously.
///
/// The input will be an `NSRange` representing the text that needs styling, and the output is a `TokenApplication`.
/// The underlying parsing system must be able to translate a request for tokens expressed as an `NSRange` into a `TokenApplication`.
///
/// This would be a lot easier to implement if the interface was purely asynchronous. However, Neon provides a fully synchronous styling path. Avoiding the need for an async context can be very useful, and makes it possible to provide a flicker-free guarantee if the underlying parsing system can process the work required in reasonable time. Your actual implementation, however, does not actually have to implement the synchronous path if that's too difficult.
public typealias TokenProvider = HybridValueProvider<NSRange, TokenApplication>

extension TokenProvider {
Expand Down

0 comments on commit 6b83e57

Please sign in to comment.