Improve docs, refine README
This commit is contained in:
parent
4000fbd155
commit
13e90cc79e
|
@ -1,7 +1,6 @@
|
|||
disabled_rules:
|
||||
- trailing_comma
|
||||
- identifier_name
|
||||
- private_over_fileprivate
|
||||
- void_return
|
||||
- operator_whitespace
|
||||
- nesting
|
||||
|
|
|
@ -79,6 +79,9 @@ An example of a Gluon component that binds a button to a label, embedded
|
|||
within an existing UIKit app, looks like this:
|
||||
|
||||
```swift
|
||||
import Gluon
|
||||
import GluonUIKit
|
||||
|
||||
struct Counter: LeafComponent {
|
||||
struct Props: Equatable {
|
||||
let countFrom: Int
|
||||
|
|
|
@ -5,6 +5,17 @@
|
|||
// Created by Max Desiatov on 06/11/2018.
|
||||
//
|
||||
|
||||
/** Type-erased version of `Equatable` that allows you to compare values of
|
||||
different types. Main use of `AnyEquatable` in Gluon is to wrap `Props` and
|
||||
`Children` before storing those in `AnyNode`.
|
||||
|
||||
Example:
|
||||
|
||||
```swift
|
||||
AnyEquatable(42) == AnyEquatable(42) // is `true`
|
||||
AnyEquatable(42) == AnyEquatable("forty two") // is `false`
|
||||
```
|
||||
*/
|
||||
public struct AnyEquatable: Equatable {
|
||||
public let value: Any
|
||||
private let equals: (Any) -> Bool
|
||||
|
|
|
@ -18,10 +18,29 @@ extension UniqueReference: Equatable {
|
|||
}
|
||||
}
|
||||
|
||||
/// `Unique` works around the fact that `ObjectIdentifier` can't take
|
||||
/// closures as arguments despite closures being reference types and having
|
||||
/// identity. `Unique` implements `Equatable`, but will return `false` on
|
||||
/// equality comparison of different identities (including closures).
|
||||
/** `Unique` works around the fact that `ObjectIdentifier` can't take
|
||||
closures as arguments despite closures being reference types and having
|
||||
identity. You can pass any value or reference to `Unique.init`, which will
|
||||
create a new identity. `Unique` implements `Equatable`, but will return
|
||||
`false` on equality comparison of different identities (including closures)
|
||||
Example:
|
||||
|
||||
```swift
|
||||
let x = Unique(5)
|
||||
let y = Unique(5)
|
||||
let z = x
|
||||
|
||||
x == y // is `false`
|
||||
x == z // is `true`
|
||||
|
||||
let closure1 = Unique { 5 }
|
||||
let closure2 = Unique { 5 }
|
||||
let closure3 = closure1
|
||||
|
||||
closure1 == closure2 // is `false`
|
||||
closure3 == closure1 // is `true`
|
||||
```
|
||||
*/
|
||||
public struct Unique<T> {
|
||||
private let id = UniqueReference()
|
||||
|
||||
|
|
Loading…
Reference in New Issue