Using Swiftโ€™s Delegate Methods with Rx

If you look into the folder named โ€˜Commonโ€™ at [Pods>RxCocoa>]you can find two swift files, DelegateProxy.swift and DelegateProxyType.swift.

DelegateProxy is a bridge that links RxSwift and Swiftโ€™s Delegate methods, which helps you to use delegate methods, like UITableViewDelegate and MKMapViewDelegate, in RxSwift/RxCocoa.

explanation inside the DelegateProxyType.swift file

Normally we would use MapKit Delegate methods like below

However, with DelegateProxy, we could use methods like the below somehow

In order to achieve that
1. make UICollectionViewDelegateProxy class
2. inherit from the DelegateProxy class

class (name)DelegateProxy
: DelegateProxy<
(a class youโ€™ll be using on), (delegate)>
, DelegateProxyType
,
(delegate) {
โ€ฆ
}

And then make methods youโ€™ll be using in extension closure

Then thatโ€™s it. All you have to do is just listen to those changes like below :)

--

--

So you write some classes and structures as we cool developers do.

And later, you need another class similar to the class you have written 3 month ago.

Retroactive Modeling, a dope technique available with Protocol Oriented Programming, is what you can use on that case, reusing written codes withโ€ฆ

--

--

์•ˆ๋…•ํ•˜์„ธ์š” :)

์˜ค๋Š˜์€ ํ”Œ๋กœ์ด๋“œ ์™€์ƒฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜์— ๋Œ€ํ•œ ํฌ์ŠคํŒ…์ž…๋‹ˆ๋‹ค.

ํ”Œ๋กœ์ด๋“œ ์™€์ƒฌ (Floyd-Warshall) ์•Œ๊ณ ๋ฆฌ์ฆ˜์€ ๋‹ค์ด๋‚˜๋ฏน ํ”„๋กœ๊ทธ๋ž˜๋ฐ์„ ๊ธฐ์ดˆ๋กœ ํ•˜๊ณ ์žˆ๋Š”๋ฐ์š”.

์ด ๋ฐฉ๋ฒ•์˜ ํ•ต์‹ฌ์€ ๊ฑฐ์ณ๊ฐ€๋Š” ์ •์ ์„ ๊ธฐ์ค€์œผ๋กœ ์ตœ๋‹จ ๊ฑฐ๋ฆฌ๋ฅผ ๊ตฌํ•˜๋Š” ๊ฒƒ ์ž…๋‹ˆ๋‹ค.

์˜ˆ์‹œ๋กœ ์ขŒ์ธก์˜ ๊ทธ๋ž˜ํ”„์˜ ์ •์  ๊ฐ„์˜ ์ด๋™ ๋น„์šฉ์„ ์•„๋ž˜์™€ ๊ฐ™์€ 2์ฐจ์› ๋ฐฐ์—ด๋กœ ๋‚˜ํƒ€๋‚ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

--

--