Skip to content

Instantly share code, notes, and snippets.

@fitomad
Created October 15, 2019 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fitomad/f61c314737175d47214d04b6f305de21 to your computer and use it in GitHub Desktop.
Save fitomad/f61c314737175d47214d04b6f305de21 to your computer and use it in GitHub Desktop.
...
// 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