-
Notifications
You must be signed in to change notification settings - Fork 1
Day 09 Rx.Net part 3
Kobi Hari edited this page Sep 17, 2020
·
1 revision
Fun With Rx.Net | Programming reative ui using Rx Operators |
- We used the The
Do
Operator to create log and allow debugging- We noticed that
Do
does not actually do anything until the observable is subscribed to - We understood the difference between
Do
andSubscribe
- We noticed that
- We saw how to create, and how not to create operators of our own
- We used subjects as HUB and created a demo where the subject turns a cold observable to hot
- We distinctify between the two roles that the subject serves when used as a hub
- It publishes the same events to all observers
- It "activates" the source by subscribing to it
- We got familiar with the
Publish
operator which serves like aSubject
-
Publish
turns a cold observable to hot - The actual subscription is deffered until the
Connect
method is called - You can use
Publish(initialValue)
to create aBehaviorPublisher
that behaves like aBehaviorSubject
- You can disconnect using the
IDisposable
returned from theConnect
method - You can use
PublishLast
to create a publisher that acts likeAsyncSubject
-
- We used the
.Publish().Refcount()
to create a publisher that automatically connects to source when the first observer subscribes to it - We subscribed the same subject to multiple observables
- We discovered that the subject completes as soon as one of the observables completes
- Which makes it a bad choice to use as a hot merging tool
- Instead we can use
Merge
- And if we want a hot merged observable we will use
Merge().Publish().RefCount()
- We turned a Hot Observable into Cold by using the
Replay
Operator
- We saw how to use Sum, Count, Max, ToList - All reactive!!!
- We saw that they return a Scalar Observable - an observable that returns a single value
- We learned how to use
Aggregate
to create a general aggregator - We saw the
Scan
Operator and realized it is just likeAggregate
except it returns sub results after each source event.
- We used the
Select
Operator to create an Observable of Observables - We saw that we can also use
GroupBy
andWindow
to transfer a flat observable into second order one. - We saw that
Buffer
is similiar toWindow
except that it returnsIObservable<IEnumerable<T>>
- We saw the The
Zip
Operator that combines 2 (or more) observables by matching events with the same index and combining them togher using a projection method - We saw the
CombineLatest
Operator and realized it is likeZip
except that it yields a combined event whenever either operand yields an event. - We saw the
WithLatestFrom
Operator which is likeCombineLatest
but not symmetrical, so it only yields events when the first observable yields them.
- We saw that the
Concat
Operator can be used to chain 2 observables- We realized that it has very different results when the observables are hot
- We also used the
Repeat
operator to resubscribe to the same observable - We saw that
Merge
andConcat
have a version where they apply on anIObservable<IObservable<T>>
rather than on a fixed number of observables.
- We saw that we can use the
Switch
operator to create an observable that returns always subscribes to the last inner observable that is created - We saw that we can use the
Amb
operator to create an observable that only stays subscribed with the first observable that yields an event.