Skip to content

Commit bdedcef

Browse files
committed
Edit L13
1 parent e0b43ea commit bdedcef

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

Lessons/Combine-Pt.3/README.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,41 @@ Declarative UI updates from user input.
6161

6262
<!-- > -->
6363

64+
## Networking
65+
66+
**URLSession** has a Combine publisher: `dataTaskPublisher`
67+
68+
The result is a tuple `(Data, URLResponse)`
69+
70+
And there's also support with **Codable** by using the operator `decode(type:decoder:)`
71+
72+
[Playground Sample Code]()
73+
74+
<aside class="notes">
75+
When using this combination, we need to first use map on the result from dataTaskPublisher, to just get the Data part of it from the tuple. Then we can apply the operator to decode it.
76+
</aside>
77+
78+
<!-- > -->
79+
6480
## Integration with Networking
6581

6682
Fetching, transforming and displaying data.
6783

68-
[Instructions](assignments/Example-2.md)
84+
[Sample Project](https://github.com/Make-School-Labs/MOB2.4-CombineEx2)
85+
86+
<!-- v -->
87+
88+
### Activity
89+
90+
Analize the sample project and observe how Combine is used to fetch and display data.
91+
92+
Make sure you identify and understand these concepts:
93+
- eraseToAnyPublisher
94+
- tryMap
95+
- replaceError
96+
- @Published variables
97+
- throttle
98+
- switchToLatest
6999

70100
<!-- > -->
71101

@@ -79,6 +109,10 @@ Combine is a new framework and it will take more reading and practice to get use
79109

80110
- [Using Combine](https://heckj.github.io/swiftui-notes/#coreconcepts-publisher-subscriber)
81111
- [Combine Concepts - Playground](https://github.com/AvdLee/CombineSwiftPlayground)
112+
- [URLSession + Combine](https://theswiftdev.com/urlsession-and-the-combine-framework/)
113+
- [Networking Layer with Combine](https://betterprogramming.pub/implement-a-networking-layer-using-combine-in-swift-5-8a83e3ac9bae)
114+
- [More Networking with Combine](https://www.vadimbulavin.com/modern-networking-in-swift-5-with-urlsession-combine-framework-and-codable/)
115+
- [Combine + UI Updates](https://useyourloaf.com/blog/getting-started-with-combine/)
82116
- Book: Practical Combine by Donny Walls
83117
- Book: Combine - Asynchronous programming with Swift By Shai Mishali, Marin Todorov, Florent Pillet and Scott Gardner
84118

Lessons/Combine-Pt.3/assignments/Example-2.md

Whitespace-only changes.
5.27 KB
Binary file not shown.

0 commit comments

Comments
 (0)