rxCocoa Flashcards

1
Q

Rules for RxCocoa traits

A

They can’t error out.

They are observed on main scheduler.

They subscribe on main scheduler.

They share resources (e.g. share(replay: 1)), except for Signal.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

RxCocoa traits

A

ControlProperty & ControlEvent
Driver
Signal

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Driver vs Signal

A

Signal is useful for modeling events, where a Driver is more suitable for modeling state.

“You might consider this trait as an alternative to Driver, but there’s an important detail you have to consider first: there’s no replay of the last event after subscription.
The difference between Driver and Signal is a bit like between BehaviorSubject and PublishSubject. After you’ve written RxSwift code for a while, you usually figure out the nuances of when to use which.
To help you decide which to use, simply ask yourself: “Do I need a replay of the last event when I connect to the resource?”
If your answer is no, then Signal is a good option; otherwise, Driver is the solution.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Driver vs Bind(to:)

A

drive works quite similarly to bind(to:); the difference in the name better expresses the intent while using RxCocoa’s Traits

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How to create flow api -> business logic -> UI

A

Divide api calls
Merge them
merge -> map -> drive

Create flows that you needed for UI components

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How to create .rx. extension for component?

A

Create Delegate Proxy

Add ControlProperty & ControlEvent that you needed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Forward proxy vs Delegate proxy

A

Forward proxy is just normal component delegate that you have to set manually on view controller.
It’s useful when you want delegate directly from component without rx

You can use Delegate Proxy and Forward Proxy

It’s useful for delegates that return values for customisation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

When I can use [unowned self]?

A

When use the same observable from transforming parameters you can use [unowned self]

    let mapInput = mapView.rx.regionDidChangeAnimated
      .skip(1)
      .map { [unowned self] _ in self.mapView.centerCoordinate }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

bind(to:) is actually

A

bind(to:) is actually an alias, or syntactic sugar, for subscribe(). Calling bind(to: observer) will internally call subscribe(observer). The former is simply in place to create a more meaningful and intuitive syntax.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly