ra1028 / Carbon

🚴 A declarative library for building component-based user interfaces in UITableView and UICollectionView.

Home Page:https://ra1028.github.io/Carbon

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Decompose `IdentifiableComponent` to `Identifiable` and `Component`

ra1028 opened this issue · comments

Checklist

Description

Decompose IdentifiableComponent to Identifiable and Component.

Motivation and Context

Use protocol composition like SwiftUI.

Proposed Solution

Use Swift.Identifiable if Swift version is greater than 5, and creates Carbon.Identifiable protocol if not.
e.g.

#if swift(<5)

public protocol Identifiable {
    associatedtype ID: Hashable

    var id: ID { get }
}

#endif

typealias IdentifiableComponent = Identifiable & Component

IdentifiableComponent will be deprecated in the future, but not now.

Swift.Identifiable depends on iOS 13 due to ABI stability. This means that can't decides whether to use Identifiable typealias at compile time.
Close this issue to avoid ambiguous type declaration in Swift.Identifiable and Carbon.Identifiable.