tobitech / code-labs

A platform agnostics repository for programming experiments, projects and algorithm implementation
1 stars 0 forks source link

The State of the Screen #1

Open RoyDeng opened 3 years ago

RoyDeng commented 3 years ago

Hello, I refer to your code to build a similar application. However, I have encountered some problems.

  1. When the next page is loaded, the state of the previous pages is reset, such as likedByUser.
  2. If I like a photo on the detail page, how do I update the status of the item in the list when I return to the previous page?

Thank you.

Papr-papr-moya-version

tobitech commented 3 years ago

Hello @RoyDeng The Project you mentioned is a fork of this project https://github.com/jdisho/Papr However, since the application uses Unsplash's API, you might have to make an API call to update the like count, that's if you don't want to reload the entire home page. You could also update the like count manually using a delegate method to notify the previous page when the detail page is dismissed, you can keep a reference to the cell (or its IndexPath) that holds the photo you just updated. I hope this helps.

RoyDeng commented 3 years ago

Hi @tobitech, I use my own API, and I use PublishSubject to update likedByUser, when I scroll to the next page, the state of previous pages is reset. In addition, How could I send a reference to the cell from another view model? Thank you.