I'm in the middle of reworking the Courses section to follow MVVM and I'm trying to introduce the Repository pattern to handle network refreshes etc. You can see my work on this branch, specifically CoursesViewModel, CourseRepository, and CoursesActivity. A couple of things that I'm still working out:
I have yet to report back any errors from the CourseRepository back to the Activity. This has a significant impact because some errors should kick the user out, and some should display an error message. I was reading up and it looks like the consensus is to wrap your object within some sort of Result object, with the state attached to it, an an optional error. Thoughts?
I also need to report back when the loading has been finished, to know when to hide my progress bar within the toolbar. If we go with the solution above, this should cover this.
The adapter needs two pieces of information to display its cells: whether the user can unregister from terms, and the courses to show. This is problematic as these are 2 different pieces of observable data, meaning that you will either update the adapter twice, or you will hope that the first observable has been properly updated before observing the second observable and updating the adapter. I'm wondering what the right way of doing this.
You can find relevant sections for these three points as TODOs, 2 within CoursesActivity, and 1 within CourseRepository. Any thoughts on any of these three points would be appreciated!
I'm in the middle of reworking the
Courses
section to follow MVVM and I'm trying to introduce theRepository
pattern to handle network refreshes etc. You can see my work on this branch, specificallyCoursesViewModel
,CourseRepository
, andCoursesActivity
. A couple of things that I'm still working out:CourseRepository
back to theActivity
. This has a significant impact because some errors should kick the user out, and some should display an error message. I was reading up and it looks like the consensus is to wrap your object within some sort ofResult
object, with the state attached to it, an an optional error. Thoughts?You can find relevant sections for these three points as
TODO
s, 2 withinCoursesActivity
, and 1 withinCourseRepository
. Any thoughts on any of these three points would be appreciated!