Skip to content

Latest commit

 

History

History
47 lines (32 loc) · 1.33 KB

README.md

File metadata and controls

47 lines (32 loc) · 1.33 KB

Compose

CI CI

What is this?

A Swift library for composing structs from other structs, which relies on the KeyPath and @dynamicMemberLookup features to provide a clean and typesafe API:

import Compose

struct Developer: Codable, Hashable {
    var name: String
    var age: Int
}

struct RemoteLocation: Codable, Hashable {
    var country: String
    var city: String
}

typealias RemoteDeveloper = Compose<Developer, RemoteLocation>

let remoteDeveloper = RemoteDeveloper(
    .init(name: "Andres", age: 26), 
    .init(country: "Spain", city: "Madrid")
)
print(remoteDeveloper.name) // Andres
print(remoteDeveloper.city) // Madrid

For an in depth explanation please follow this link.

Installation

Swift Package Manager

Add the following to the dependencies inside your Package.swift file:

.package(url: "https://github.com/acecilia/Compose.git", .upToNextMajor(from: "0.0.1")),

License

Compose is licensed under the MIT license. See LICENSE for more info.