From the course: RxSwift: Design Patterns for iOS Developers
Unlock this course with a free trial
Join today to access over 22,400 courses taught by industry experts.
Traits - Swift Tutorial
From the course: RxSwift: Design Patterns for iOS Developers
Traits
- [Instructor] The next type to talk about are traits, which are just specialized observables. I don't think it's worth your time to watch me type all of this out because you will be using these in a template form over and over again, and so I've provided a file inside of your exercise files. Under the starter project, there's a file called TraitsRx.swift. Let's go ahead and bring this over to our project and put it in the simple examples folder and let's go ahead and take a look at what this TraitsRx file looks like. It's just a singleton, and we have a DisposeBag, but the pieces I want you to focus on are lines 11, lines 35, and line 60. Each of these has an example for the different type of traits you would be using. Traits are really similar to observables in how we create them, the set of observables and type out create. We'll say single type dot create. The only other difference in here is that instead of posting an event like on next or on error, we're actually just using the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.