Skip to content

Commit d35adde

Browse files
committed
Update README.md
1 parent 9de1b80 commit d35adde

File tree

1 file changed

+41
-47
lines changed

1 file changed

+41
-47
lines changed

README.md

Lines changed: 41 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,18 @@
11
# Swift Declarative Configuration
22

3-
[![Test](https://github.com/CaptureContext/swift-declarative-configuration/actions/workflows/Test.yml/badge.svg)](https://github.com/CaptureContext/swift-declarative-configuration/actions/workflows/Test.yml) [![SwiftPM 6](https://img.shields.io/badge/swiftpm-6-ED523F.svg?style=flat)](https://swift.org/download/) ![Platforms](https://img.shields.io/badge/platforms-iOS_11_|_macOS_10.13_|_tvOS_11_|_watchOS_4_|_Catalyst_13-ED523F.svg?style=flat) [![@capture_context](https://img.shields.io/badge/contact-@capture__context-1DA1F2.svg?style=flat&logo=twitter)](https://twitter.com/capture_context)
3+
[![Test](https://github.com/CaptureContext/swift-declarative-configuration/actions/workflows/Test.yml/badge.svg)](https://github.com/CaptureContext/swift-declarative-configuration/actions/workflows/Test.yml) [![SwiftPM 6.0](https://img.shields.io/badge/swiftpm-6.0-ED523F.svg?style=flat)](https://swift.org/download/) ![Platforms](https://img.shields.io/badge/platforms-iOS_11_|_macOS_10.13_|_tvOS_11_|_watchOS_4_|_Catalyst_13-ED523F.svg?style=flat) [![@capture_context](https://img.shields.io/badge/contact-@capture__context-1DA1F2.svg?style=flat&logo=twitter)](https://twitter.com/capture_context)
44

55
Swift Declarative Configuration (SDC, for short) is a tiny library, that enables you to configure your objects in a declarative, consistent and understandable way, with ergonomics in mind. It can be used to configure any objects on any platform, including server-side-swift.
66

7-
## Products
7+
## Features
88

9-
- **[FunctionalModification](./Sources/FunctionalModification)**
9+
- **[Configurator](./Sources/DeclarativeConfiguration/Configurator/Configurator.swift)**
1010

11-
Provides modification functions for copying and modifying immutable stuff. It is useful for self-configuring objects like builder, when modifying methods should return modified `self`.
11+
Functional configurator for anything, enables you to specify modification of an object and to apply the modification later. Primary way of declaring configurations for your objects.
1212

13-
- **[FunctionalKeyPath](./Sources/FunctionalKeyPath)**
13+
- **[Builder](./Sources/DeclarativeConfiguration/Configurator/Builder.swift)**
1414

15-
Functional KeyPath wrapper.
16-
17-
- **[FunctionalConfigurator](./Sources/FunctionalConfigurator)**
18-
19-
Functional configurator for anything, enables you to specify modification of an object and to apply the modification later.
20-
21-
Also contains self-implementing protocols (`ConfigInitializable`, `CustomConfigurable`) to enable you add custom configuration support for your types (`NSObject` already conforms to it for you).
22-
23-
- **[FunctionalBuilder](./Sources/FunctionalBuilder)**
24-
25-
Functional builder for anything, enables you to modify object instances in a declarative way. Also contains `BuilderProvider` protocol with a computed `builder` property and implements that protocol on `NSObject` type.
26-
27-
- **[FunctionalClosures](./Sources/FunctionalClosures)**
28-
29-
Functional closures allow you to setup functional handlers & datasources, the API may seem a bit strange at the first look, so feel free to ask or discuss anything [here](https://github.com/MakeupStudio/swift-declarative-configuration/issues/1).
30-
31-
- **[DeclarativeConfiguration](./Sources/DeclarativeConfiguration)**
32-
33-
Wraps and exports all the products.
15+
Functional builder for anything, enables you to modify object instances in a declarative way. Also contains `BuilderProvider` protocol with a computed `builder` property and implements that protocol on `NSObject` type.vBuilder-style way of declaring configurations for your objects. Suitable for instantiated objects.
3416

3517
## Basic Usage
3618

@@ -55,15 +37,16 @@ class ImageViewController: UIViewController {
5537
}
5638
```
5739

58-
### FunctionalConfigurator
40+
### Configurator
5941

60-
> **Note:** This way is **recommended**, but remember, that custom types **MUST** implement initializer with no parameters even if the superclass already has it or you will get a crash otherwise.
42+
> [!NOTE]
43+
> _This way is **recommended**._
6144
6245
```swift
63-
import FunctionalConfigurator
46+
import DeclarativeConfiguration
6447

6548
class ImageViewController: UIViewController {
66-
let imageView = UIImageView { $0
49+
let imageView = UIImageView() { $0
6750
.contentMode(.scaleAspectFit)
6851
.backgroundColor(.black)
6952
.layer.scope { $0
@@ -78,12 +61,10 @@ class ImageViewController: UIViewController {
7861
}
7962
```
8063

81-
### FunctionalBuilder
82-
83-
> **Note:** This way is recommended too, and it is more **safe**, because it modifies existing objects.
64+
### Builder
8465

8566
```swift
86-
import FunctionalBuilder
67+
import DeclarativeConfiguration
8768

8869
class ImageViewController: UIViewController {
8970
let imageView = UIImageView().builder
@@ -104,6 +85,8 @@ class ImageViewController: UIViewController {
10485
- `reduce(_:with:)`:
10586

10687
```swift
88+
import DeclarativeConfiguration
89+
10790
struct CounterState {
10891
var value: Int = 0
10992
}
@@ -119,6 +102,9 @@ class ImageViewController: UIViewController {
119102

120103
### FunctionalClosures
121104

105+
> [!WARNING]
106+
> _Deprecated_
107+
122108
### No SDC
123109

124110
**Declaration**
@@ -221,8 +207,6 @@ If your deployment target is iOS 17+ (or other platform with a corresponding ver
221207

222208
### More
223209

224-
#### Builder
225-
226210
Customize any object by passing initial value to a builder
227211

228212
```swift
@@ -248,6 +232,26 @@ let object = Object { $0
248232
}
249233
```
250234

235+
or batch-scoping
236+
237+
```swift
238+
let object = Object { $0
239+
.property.scope { $0
240+
.subproperty1(value)
241+
.subproperty2(value)
242+
}
243+
}
244+
```
245+
246+
```swift
247+
let object = Object { $0
248+
.property.ifLetScope { $0 // if property is optional
249+
.subproperty1(value)
250+
.subproperty2(value)
251+
}
252+
}
253+
```
254+
251255
Conform your own types to `BuilderProvider` protocol to access builder property.
252256

253257
```swift
@@ -258,16 +262,6 @@ extension CLLocationCoordinate2D: BuilderProvider {}
258262
// Now you can access `location.builder.latitude(0).build()`
259263
```
260264

261-
#### Configurator
262-
263-
> **Note:** Your NSObject classes **must** implement `init()` to use Configurators. It's a little trade-off for the convenience it brings to your codebase, see [tests](./Tests/DeclarativeConfigurationTests/ConfiguratorTests.swift) for an example.
264-
265-
#### DataSource
266-
267-
`OptionalDataSource` and `DataSource` types are very similar to the `Handler`, but if `Handler<Input>` is kinda `OptionalDataSource<Input, Void>`, the second one may have different types of an output. Usage is similar, different types are provided just for better semantics.
268-
269-
If your deployment target is iOS 17+ (or other platform with a corresponding version) you can use beta variadic generic `_DataSource` type
270-
271265
## Installation
272266

273267
### Basic
@@ -284,8 +278,8 @@ If you use SwiftPM for your project structure, add DeclarativeConfiguration to y
284278

285279
```swift
286280
.package(
287-
url: "git@github.com:capturecontext/swift-declarative-configuration.git",
288-
.upToNextMinor(from: "0.4.0")
281+
url: "git@github.com:capturecontext/swift-declarative-configuration.git",
282+
.upToNextMinor(from: "1.0.0-beta.1")
289283
)
290284
```
291285

@@ -294,7 +288,7 @@ or via HTTPS
294288
```swift
295289
.package(
296290
url: "https://github.com:capturecontext/swift-declarative-configuration.git",
297-
.upToNextMinor("0.4.0")
291+
.upToNextMinor(from: "1.0.0-beta.1")
298292
)
299293
```
300294

0 commit comments

Comments
 (0)