6. Functional Programming
First and foremost, functional programming is not a language or a syntax¹ , but rather a
programming paradigm — a way of solving problems by decomposing complicated processes
into simpler ones
● Functional Programming Concepts
○ immutable state
○ lack of side effects
9. Reactive Programming
Reactive Programming is an asynchronous programming paradigm concerned with data streams
and the propagation of change. ReactiveX or Rx is the most popular API for reactive programming. It's
built on the ideologies of the Observable Pattern, Iterator Pattern, and Functional Programming
10. What is RxSwift ?
RxSwift is a library for composing asynchronous and event-based code by using observable
sequences and functional style operators, allowing for parameterized execution via
schedulers.
in its essence, simplifies developing asynchronous programs by allowing your code to react to
new data and process it in sequential, isolated manner.
11. Why RxSwift
UI programming is mostly about reacting to some asynchronous tasks. We’re taught to implement that
with observer patterns: I’m pretty sure you’re familiar with delegates by now. Delegating is a cool pattern,
but it gets really tiring…
19. Hot vs Cold Observables
When the data is produced by the Observable itself, we call it a cold Observable.
When the data is produced outside the Observable, we call it a hot Observable.
20. Scheduler
it’s important to understand what they are — and what they are not. To summarize,
a scheduler is a context where a process takes place. This context can be a thread,
a dispatch queue or similar entities, or even an NSOperation which is used inside
the OperationQueueScheduler.
Here’s a good example as to how schedulers can be used:
21. Using subscribeOn
When you want to actually observe an
observable, you subscribe to it. This determines where the original processing will
happen. If subscribeOn is not called, then RxSwift automatically uses the current
thread:
23. Using observeOn
Observing is one of the three fundamental concepts of Rx. It involves an entity
producing events, and an observer for those events. In this case, and in opposition
to subscribeOn, the operator observeOn changes the scheduler where the
observation happens.
26. Needed Example
Create collectionview for exchange currency convertor from EURO
API -> https://api.exchangeratesapi.io/latest
Email: -> eng.sally.ahmed@gmail.com
38. Driver
Driver is a special observable with the same constraints as explained before, so it
can’t error out. All processes are ensured to execute on the main thread, which
avoids making UI changes on background threads.
40. ControlEvent
ControlEvent is used to listen to a certain event of the UI component, like the
pressof the “Return” button on the keyboard while editing a text field. A control
event isavailable if the component uses UIControlEvents to keep track of its
current status.
41. Subjects
You’ve gotten a handle on what an observable is, how you create one, how to
subscribe to it, and how to dispose of things when you’re done. Observables are a
fundamental part of RxSwift, but a common need when developing apps is to
manually add new values onto an observable at runtime that will then be emitted to
subscribers. What you want is something that can act as both an observable and
as an observer. And that something is called a Subject.
46. Solid Principles
● Single Responsibility Principle
○ Every part in the application should do one and only one thing, starting
from the level of methods and functions, to classes, even to packages …
everything should have only one reason to change
47. Solid Principles
● Open Closed Principle
○ Every class should be open for extension / inheritance, but closed for
modification, which means that if we have a class that makes something,
and we want to make this class do another thing, we should not modify
this class, but we can create a subclass that does this new thing, or we
can make extension functions for that class
48. Solid Principles
● Liskov Substitution Principle
○ When we use a subclass instead of the superclass, this behavior should
not break the software, in other words, we do not override methods in our
subclass and make it crash or misbehave when used
49. Solid Principles
● Interface Segregation Principle
○ Never declare methods in an interface that one of it's implementing
classes won’t need to override, same goes for abstract classes
50. Solid Principles
● Dependency Inversion Principle
○ Try to deal with the parent types as much as possible, try to deal with
interfaces or abstract classes as much as possible, this will make the
software more flexible and easy to change