Skip to content

Commit f55b532

Browse files
committedJun 19, 2019
Add CSV sorting and additional core components
1 parent 0f6ab7c commit f55b532

File tree

6 files changed

+130
-88
lines changed

6 files changed

+130
-88
lines changed
 

‎Data/core_components.csv

+23-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
1-
RxSwift,Combine,Notes
2-
Observable,Publisher,
3-
Driver,"BindableObject (SwiftUI)","Both guarantee no failure, but Driver guarantees delivery on Main Thread. In Combine, SwiftUI recreates the entire view hierarachy on the Main Thread, instead."
4-
Single,Future,
5-
Disposable,Cancellable,"There's no DisposeBag in Combine, AnyCancellable cancels on deinit."
6-
Observer,Subscriber,
7-
ConnectableObservableType,ConnectablePublisher,
8-
SubjectType,Subject,
9-
PublishSubject,PassthroughSubject,
10-
BehaviorSubject,CurrentValueSubject,"This seems to be the type that holds @State under the hood"
11-
SchedulerType,Scheduler,
1+
RxSwift,Combine,Notes
2+
AnyObserver,AnySubscriber,
3+
BehaviorRelay,❌,"Simple wrapper around BehaviorSubject, could be easily recreated in Combine"
4+
BehaviorSubject,CurrentValueSubject,This seems to be the type that holds @State under the hood
5+
Completable,❌,
6+
CompositeDisposable,❌,
7+
ConnectableObservableType,ConnectablePublisher,
8+
Disposable,Cancellable,
9+
DisposeBag,❌,
10+
Driver,BindableObject (SwiftUI),"Both guarantee no failure, but Driver guarantees delivery on Main Thread. In Combine, SwiftUI recreates the entire view hierarachy on the Main Thread, instead."
11+
Maybe,❌,
12+
Observable,Publisher,
13+
Observer,Subscriber,
14+
PublishRelay,❌,"Simple wrapper around PublishSubject, could be easily recreated in Combine"
15+
PublishSubject,PassthroughSubject,
16+
ReplaySubject,❌,
17+
ScheduledDisposable,❌,
18+
SchedulerType,Scheduler,
19+
SerialDisposable,❌,
20+
Signal,❌,
21+
Single,Future,Single behaves differently than Future. Seems the latter has no auto-disposal when finished
22+
SubjectType,Subject,
23+
TestScheduler,❌,There doesn't seem to be an existing testing scheduler for Combine code

‎Data/operators.csv

+68-67
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,68 @@
1-
RxSwift,Combine,Notes
2-
asObservable(),eraseToAnyPublisher(),
3-
asObserver(),eraseToAnySubject(),
4-
bind(to:),`assign(to:on:)`,Assign uses a KeyPath which is really nice and useful. RxSwift needs a Binder / ObserverType to bind to.
5-
buffer,buffer,
6-
catchError,catch,
7-
catchErrorJustReturn,replaceError(with:),
8-
combineLatest,"combineLatest, tryCombineLatest",
9-
compactMap,"compactMap, tryCompactMap",
10-
concat,"append, prepend",
11-
concatMap,❌,
12-
create,AnyPublisher,"AnyPublisher has an initializer with an anonymous closure, similar to Observable.create"
13-
debounce,debounce,
14-
debug,print,
15-
ifEmpty(default:),❌,
16-
ifEmpty(switchTo:),replaceEmpty(with:),
17-
deferred,Publishers.Deferred,
18-
delay,delay,
19-
delaySubscription,❌,
20-
dematerialize,❌,
21-
distinctUntilChanged,"removeDuplicates, tryRemoveDuplicates",
22-
do,handleEvents,
23-
elementAt,output(at:),
24-
empty,❌,
25-
enumerated,❌,
26-
error,Publishers.Once,Publishers.Once has an initializer that takes an Error
27-
filter,"filter, tryFilter",
28-
first,"first, tryFirst",
29-
flatMap,flatMap,
30-
flatMapFirst,❌,
31-
flatMapLatest,switchToLatest,
32-
from,❌,
33-
groupBy,❌,
34-
ignoreElements,ignoreOutput,
35-
interval,❌,
36-
just,Publishers.Just,
37-
map,"map, tryMap",
38-
materialize,❌,
39-
merge,"merge, tryMerge",
40-
multicast,multicast,
41-
never,❌,
42-
observeOn,receive(on:),
43-
of,❌,
44-
range,❌,
45-
reduce,"reduce, tryReduce",
46-
repeatElement,❌,
47-
"retry, retry(3)","retry, retry(3)",
48-
retryWhen,❌,
49-
sample,❌,
50-
scan,"scan, tryScan",
51-
share,share,"There’s no replay in Combine, and no scope. Could be “faked” with multicast."
52-
skip(3),dropFirst(3),
53-
skipUntil,drop(untilOutputFrom:),
54-
skipWhile,"drop(while:), tryDrop(while:)",
55-
startWith,❌,
56-
subscribe,sink,
57-
subscribeOn,subscribe(on:),"RxSwift uses Schedulers Combine uses RunLoop, DispatchQueue, and OperationQueue."
58-
take(3).toArray(),collect(3),
59-
takeLast,last,
60-
takeUntil,prefix(untilOutputFrom:),
61-
throttle,throttle,
62-
timeout,timeout,
63-
timer,❌,
64-
toArray(),collect(),
65-
window,collect(Publishers.TimeGroupingStrategy),Combine has a TimeGroupingStrategy.byTimeOrCount that could be used as a window.
66-
withLatestFrom,❌,
67-
zip,zip,
1+
RxSwift,Combine,Notes
2+
amb(),❌,
3+
asObservable(),eraseToAnyPublisher(),
4+
asObserver(),eraseToAnySubject(),
5+
bind(to:),`assign(to:on:)`,Assign uses a KeyPath which is really nice and useful. RxSwift needs a Binder / ObserverType to bind to.
6+
buffer,buffer,
7+
catchError,catch,
8+
catchErrorJustReturn,replaceError(with:),
9+
combineLatest,"combineLatest, tryCombineLatest",
10+
compactMap,"compactMap, tryCompactMap",
11+
concat,"append, prepend",
12+
concatMap,❌,
13+
create,AnyPublisher,"AnyPublisher has an initializer with an anonymous closure, similar to Observable.create"
14+
debounce,debounce,
15+
debug,print,
16+
deferred,Publishers.Deferred,
17+
delay,delay,
18+
delaySubscription,❌,
19+
dematerialize,❌,
20+
distinctUntilChanged,"removeDuplicates, tryRemoveDuplicates",
21+
do,handleEvents,
22+
elementAt,output(at:),
23+
empty,❌,
24+
enumerated,❌,
25+
error,Publishers.Once,Publishers.Once has an initializer that takes an Error
26+
filter,"filter, tryFilter",
27+
first,"first, tryFirst",
28+
flatMap,flatMap,
29+
flatMapFirst,❌,
30+
flatMapLatest,switchToLatest,
31+
from,❌,
32+
groupBy,❌,
33+
ifEmpty(default:),❌,
34+
ifEmpty(switchTo:),replaceEmpty(with:),
35+
ignoreElements,ignoreOutput,
36+
interval,❌,
37+
just,Publishers.Just,
38+
map,"map, tryMap",
39+
materialize,❌,
40+
merge,"merge, tryMerge",
41+
multicast,multicast,
42+
never,❌,
43+
observeOn,receive(on:),
44+
of,❌,
45+
range,❌,
46+
reduce,"reduce, tryReduce",
47+
repeatElement,❌,
48+
"retry, retry(3)","retry, retry(3)",
49+
retryWhen,❌,
50+
sample,❌,
51+
scan,"scan, tryScan",
52+
share,share,"There’s no replay in Combine, and no scope. Could be “faked” with multicast."
53+
skip(3),dropFirst(3),
54+
skipUntil,drop(untilOutputFrom:),
55+
skipWhile,"drop(while:), tryDrop(while:)",
56+
startWith,❌,
57+
subscribe,sink,
58+
subscribeOn,subscribe(on:),"RxSwift uses Schedulers Combine uses RunLoop, DispatchQueue, and OperationQueue."
59+
take(3).toArray(),collect(3),
60+
takeLast,last,
61+
takeUntil,prefix(untilOutputFrom:),
62+
throttle,throttle,
63+
timeout,timeout,
64+
timer,❌,
65+
toArray(),collect(),
66+
window,collect(Publishers.TimeGroupingStrategy),Combine has a TimeGroupingStrategy.byTimeOrCount that could be used as a window.
67+
withLatestFrom,❌,
68+
zip,zip,

‎README.md

+21-8
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,35 @@ It's based on the following blog post: [https://medium.com/gett-engineering/rxsw
1919

2020
| RxSwift | Combine | Notes |
2121
|---------------------------|--------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
22-
| Observable | Publisher | |
22+
| AnyObserver | AnySubscriber | |
23+
| BehaviorRelay || Simple wrapper around BehaviorSubject, could be easily recreated in Combine |
24+
| BehaviorSubject | CurrentValueSubject | This seems to be the type that holds @State under the hood |
25+
| Completable || |
26+
| CompositeDisposable || |
27+
| ConnectableObservableType | ConnectablePublisher | |
28+
| Disposable | Cancellable | |
29+
| DisposeBag || |
2330
| Driver | BindableObject (SwiftUI) | Both guarantee no failure, but Driver guarantees delivery on Main Thread. In Combine, SwiftUI recreates the entire view hierarachy on the Main Thread, instead. |
24-
| Single | Future | |
25-
| Disposable | Cancellable | There's no DisposeBag in Combine, AnyCancellable cancels on deinit. |
31+
| Maybe | | |
32+
| Observable | Publisher | |
2633
| Observer | Subscriber | |
27-
| ConnectableObservableType | ConnectablePublisher | |
28-
| SubjectType | Subject | |
34+
| PublishRelay || Simple wrapper around PublishSubject, could be easily recreated in Combine |
2935
| PublishSubject | PassthroughSubject | |
30-
| BehaviorSubject | CurrentValueSubject | This seems to be the type that holds @State under the hood |
36+
| ReplaySubject || |
37+
| ScheduledDisposable || |
3138
| SchedulerType | Scheduler | |
39+
| SerialDisposable || |
40+
| Signal || |
41+
| Single | Future | Single behaves differently than Future. Seems the latter has no auto-disposal when finished |
42+
| SubjectType | Subject | |
43+
| TestScheduler || There doesn't seem to be an existing testing scheduler for Combine code |
3244

3345

3446
## [Operators](Data/operators.csv)
3547

3648
| RxSwift | Combine | Notes |
3749
|----------------------|------------------------------------------|----------------------------------------------------------------------------------------------------------|
50+
| amb() || |
3851
| asObservable() | eraseToAnyPublisher() | |
3952
| asObserver() | eraseToAnySubject() | |
4053
| bind(to:) | `assign(to:on:)` | Assign uses a KeyPath which is really nice and useful. RxSwift needs a Binder / ObserverType to bind to. |
@@ -48,8 +61,6 @@ It's based on the following blog post: [https://medium.com/gett-engineering/rxsw
4861
| create | AnyPublisher | AnyPublisher has an initializer with an anonymous closure, similar to Observable.create |
4962
| debounce | debounce | |
5063
| debug | print | |
51-
| ifEmpty(default:) || |
52-
| ifEmpty(switchTo:) | replaceEmpty(with:) | |
5364
| deferred | Publishers.Deferred | |
5465
| delay | delay | |
5566
| delaySubscription || |
@@ -67,6 +78,8 @@ It's based on the following blog post: [https://medium.com/gett-engineering/rxsw
6778
| flatMapLatest | switchToLatest | |
6879
| from || |
6980
| groupBy || |
81+
| ifEmpty(default:) || |
82+
| ifEmpty(switchTo:) | replaceEmpty(with:) | |
7083
| ignoreElements | ignoreOutput | |
7184
| interval || |
7285
| just | Publishers.Just | |

‎Resources/core_components.jpg

131 KB
Loading

‎Resources/operators.jpg

6.69 KB
Loading

‎generate.rb

+18-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
require 'commonmarker'
77
require 'imgkit'
88
require 'colorize'
9+
require 'csv'
910

1011
docs = {
1112
"basics.csv" => "Basics",
@@ -20,9 +21,24 @@
2021
puts "Rebuilding README.md ...".magenta
2122

2223
docs.each { |file, title|
24+
csv_path = "Data/#{file}"
25+
26+
## Sort CSVs (aside for basics)
27+
unless file == "basics.csv" then
28+
csv = CSV.read(csv_path)
29+
body = csv.drop(1).sort! { |a, b| a[0].to_s <=> b[0].to_s }
30+
rows = body
31+
32+
csvOutput = CSV.generate_line(csv[0])
33+
csvOutput += rows.inject([]) { |csv, row| csv << CSV.generate_line(row) }
34+
.join()
35+
36+
File.write(csv_path, csvOutput)
37+
end
38+
2339
## Generate markdown for the specific section
24-
output += "## [#{title}](Data/#{file})\n\n"
25-
table = `csv2md Data/#{file}`
40+
output += "## [#{title}](#{csv_path})\n\n"
41+
table = `csv2md #{csv_path}`
2642
output += table
2743
output += "\n\n"
2844

0 commit comments

Comments
 (0)
Failed to load comments.