You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
9
6
@@ -43,66 +40,65 @@ Swift Declarative Configuration (SDC, for short) is a tiny library, that enables
43
40
44
41
```swift
45
42
classImageViewController: UIViewController {
43
+
let imageView: UIImageView = {
46
44
let imageView =UIImageView()
45
+
imageView.contentMode= .scaleAspectFit
46
+
imageView.backgroundColor= .black
47
+
imageView.layer.masksToBounds=true
48
+
imageView.layer.cornerRadius=10
49
+
return imageView
50
+
}()
47
51
48
-
overridefuncloadView() {
49
-
self.view= imageView
50
-
}
51
-
52
-
overridefuncviewDidLoad() {
53
-
super.viewDidLoad()
54
-
imageView.contentMode= .scaleAspectFit
55
-
imageView.backgroundColor= .black
56
-
imageView.layer.masksToBounds=true
57
-
imageView.layer.cornerRadius=10
58
-
}
52
+
overridefuncloadView() {
53
+
self.view= imageView
54
+
}
59
55
}
60
56
```
61
57
62
58
### FunctionalConfigurator
63
59
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.
61
+
64
62
```swift
65
63
importFunctionalConfigurator
66
64
67
65
classImageViewController: UIViewController {
68
-
69
-
let imageView =UIImageView { $0
70
-
.contentMode(.scaleAspectFit)
71
-
.backgroundColor(.black)
72
-
.layer.masksToBounds(true)
73
-
.layer.cornerRadius(10)
66
+
let imageView =UIImageView { $0
67
+
.contentMode(.scaleAspectFit)
68
+
.backgroundColor(.black)
69
+
.layer.scope { $0
70
+
.masksToBounds(true)
71
+
.cornerRadius(10)
74
72
}
73
+
}
75
74
76
-
overridefuncloadView() {
77
-
self.view= imageView
78
-
}
79
-
75
+
overridefuncloadView() {
76
+
self.view= imageView
77
+
}
80
78
}
81
79
```
82
80
83
-
**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.
84
-
85
81
### FunctionalBuilder
86
82
83
+
> **Note:** This way is recommended too, and it is more **safe**, because it modifies existing objects.
84
+
87
85
```swift
88
86
importFunctionalBuilder
89
87
90
88
classImageViewController: UIViewController {
91
-
let imageView =UIImageView().builder
92
-
.contentMode(.scaleAspectFit)
93
-
.backgroundColor(.black)
94
-
.layer.masksToBounds(true)
95
-
.layer.cornerRadius(10)
96
-
.build()
89
+
let imageView =UIImageView().builder
90
+
.contentMode(.scaleAspectFit)
91
+
.backgroundColor(.black)
92
+
.layer.masksToBounds(true)
93
+
.layer.cornerRadius(10)
94
+
.build()
97
95
98
-
overridefuncloadView() {
99
-
self.view= imageView
100
-
}
96
+
overridefuncloadView() {
97
+
self.view= imageView
98
+
}
101
99
}
102
100
```
103
101
104
-
Note: This way is recommended too, and it is more **safe**, because it modifies existing objects.
105
-
106
102
### FunctionalClosures
107
103
108
104
### No SDC
@@ -111,25 +107,25 @@ Note: This way is recommended too, and it is more **safe**, because it modifies
`OptiomalDataSource` 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.
249
+
`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.
244
250
245
251
## Installation
246
252
@@ -254,15 +260,21 @@ You can add DeclarativeConfiguration to an Xcode project by adding it as a packa
254
260
255
261
### Recommended
256
262
257
-
If you use SwiftPM for your project, you can add DeclarativeConfiguration to your package file. Also my advice will be to use SSH.
263
+
If you use SwiftPM for your project structure, add DeclarativeConfiguration to your package file.
0 commit comments