Skip to content

Commit e47f025

Browse files
committed
Updated docs
1 parent a01971e commit e47f025

File tree

4 files changed

+54
-2
lines changed

4 files changed

+54
-2
lines changed

docs/Mini.swift

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ public typealias MiddlewareChain = (Mini.Action, Mini.Chain) -> Mini.Action
136136

137137
public typealias Next = (Mini.Action) -> Mini.Action
138138

139+
public protocol OptionalType {
140+
associatedtype Wrapped
141+
142+
var value: Self.Wrapped? { get }
143+
}
144+
139145
/**
140146
An Ordered Set is a collection where all items in the set follow an ordering,
141147
usually ordered from 'least' to 'most'. The way you value and compare items
@@ -323,7 +329,7 @@ extension Store {
323329
extension Store {
324330
public func dispatch<A>(_ action: @autoclosure @escaping () -> A) -> RxSwift.Observable<Mini.Store<State, StoreController>.State> where A: Mini.Action
325331

326-
public func withStateChanges<T>(in stateComponent: @autoclosure @escaping () -> KeyPath<Mini.Store<State, StoreController>.Element, T>) -> RxSwift.Observable<T>
332+
public func withStateChanges<T>(in stateComponent: KeyPath<Mini.Store<State, StoreController>.Element, T>) -> RxSwift.Observable<T>
327333
}
328334

329335
public protocol StoreType {
@@ -375,6 +381,11 @@ extension Dictionary {
375381
public subscript(unwrapping _: Key) -> Value! { get }
376382
}
377383

384+
extension Optional: Mini.OptionalType {
385+
/// Cast `Optional<Wrapped>` to `Wrapped?`
386+
public var value: Wrapped? { get }
387+
}
388+
378389
extension ObservableType {
379390
/// Take the first element that matches the filter function.
380391
///
@@ -389,13 +400,26 @@ extension ObservableType {
389400
public func one() -> RxSwift.Observable<Self.Element>
390401

391402
public func skippingCurrent() -> RxSwift.Observable<Self.Element>
403+
404+
/**
405+
Selects a property component from an `Element` filtering `nil` and emitting only distinct contiguous elements.
406+
*/
407+
public func select<T>(_ keyPath: KeyPath<Self.Element, T>) -> RxSwift.Observable<T.Wrapped> where T: Mini.OptionalType, T.Wrapped: Equatable
408+
}
409+
410+
extension ObservableType where Self.Element: Mini.OptionalType {
411+
/**
412+
Unwraps and filters out `nil` elements.
413+
- returns: `Observable` of source `Observable`'s elements, with `nil` elements filtered out.
414+
*/
415+
public func filterNil() -> RxSwift.Observable<Self.Element.Wrapped>
392416
}
393417

394418
extension ObservableType where Self.Element: Mini.StateType {
395419
/**
396420
Maps from a `StateType` property to create an `Observable` that contains the filtered property and all its changes.
397421
*/
398-
public func withStateChanges<T>(in stateComponent: @autoclosure @escaping () -> KeyPath<Self.Element, T>, that componentProperty: @autoclosure @escaping () -> KeyPath<T, Bool>) -> RxSwift.Observable<T>
422+
public func withStateChanges<T>(in stateComponent: KeyPath<Self.Element, T>, that componentProperty: KeyPath<T, Bool>) -> RxSwift.Observable<T>
399423
}
400424

401425
prefix operator ^

docs/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- [Chain](protocols/Chain.md)
55
- [Group](protocols/Group.md)
66
- [Middleware](protocols/Middleware.md)
7+
- [OptionalType](protocols/OptionalType.md)
78
- [Service](protocols/Service.md)
89
- [StateType](protocols/StateType.md)
910
- [StoreType](protocols/StoreType.md)
@@ -33,6 +34,7 @@
3334
- [Action](extensions/Action.md)
3435
- [Dictionary](extensions/Dictionary.md)
3536
- [ObservableType](extensions/ObservableType.md)
37+
- [Optional](extensions/Optional.md)
3638
- [StateType](extensions/StateType.md)
3739
- [Store](extensions/Store.md)
3840
- [StoreType](extensions/StoreType.md)

docs/extensions/Optional.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
**EXTENSION**
2+
3+
# `Optional`
4+
5+
## Properties
6+
### `value`
7+
8+
```swift
9+
public var value: Wrapped?
10+
```
11+
12+
> Cast `Optional<Wrapped>` to `Wrapped?`

docs/protocols/OptionalType.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
**PROTOCOL**
2+
3+
# `OptionalType`
4+
5+
```swift
6+
public protocol OptionalType
7+
```
8+
9+
## Properties
10+
### `value`
11+
12+
```swift
13+
var value: Wrapped?
14+
```

0 commit comments

Comments
 (0)