RecyclerView Not Updating Edits and Deletes till Swiperefresh
Can you please test Open-Api where you delete a blog, It looks like SHOULD_REFRESH is not refreshing the blogList!, I think you have missed BlogEvent.Refresh, I may be wrong UpdateBlog Reflect Nicely on ViewBlog But does not filter through to ListBlog
remove this bloc from BlogViewModel : //// init { onTriggerEvent(BlogEvents.GetOrderAndFilter) } //// and add this to the onViewCreated() in BlogFragment : //// onTriggerEvent(BlogEvents.GetOrderAndFilter)
You mean in BlogFragment viewModel.onTriggerEvent(BlogEvents.GetOrderAndFilter)
The problem with this it is forced not by trigger!
The problem having this is it generate extra Network traffic - Even if Change was NOT made! AND Loding keeps Spinnig!!
I'd think Mitch will have a different solution, but it works! Thanx
@Zlagi You put me on the correct Track However
Add in BlogFragment onViewCreated
// If an update occurred from UpdateBlogFragment, refresh the Blog findNavController().currentBackStackEntry?.savedStateHandle?.getLiveData<Boolean>(SHOULD_REFRESH) ?.observe(viewLifecycleOwner) { shouldRefresh -> shouldRefresh?.run { viewModel.onTriggerEvent(BlogEvents.GetOrderAndFilter) findNavController().currentBackStackEntry?.savedStateHandle?.set(SHOULD_REFRESH, null) } }
Remove from ViewBlogFragment the line that re-set the flag SHOULD_REFRESH so that it is still there for the BlogFragment
findNavController().currentBackStackEntry?.savedStateHandle?.set(SHOULD_REFRESH, null)
The BlogFragment will then Re-Set the flag! if needed and would cause NO extra traffic plus the isLoading is working correct!
Works as Intended!
It's not as simple as you suggested. If you refresh in BlogFragment the list position is lost. We would need a use-case that only updates that specific blogpost in the list. Feel free to write it :)
Ok I guess you will sort that, I have mostly tested on the Top blog 👍
I had a thought Maybe if you refresh the changed data to the Server and re-cache it before returning to the Recycler view you will get the changed record in there and keep your location, Replacing the need for SHOULD_REFRESH 100% all places! @mitchtabian As us suggested!