Created
October 15, 2019 13:47
-
-
Save fitomad/f61c314737175d47214d04b6f305de21 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
// Recuperamos el estado actual de la sesión | |
self.isFavorite = DataManager.shared.existsFavoriteSesssion(named: session.title) | |
$isFavorite | |
// 1 | |
.dropFirst() | |
// 2 | |
.receive(on: RunLoop.main) | |
// 3 | |
.sink(receiveValue: { (favorited: Bool) -> Void in | |
if favorited | |
{ | |
DataManager.shared.insertFavoriteSession(named: session.title, backdrop: session.imageURL) | |
} | |
else | |
{ | |
DataManager.shared.deleteFavoriteSession(named: session.title) | |
} | |
}) | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment