Comments (9)
First create a service layer, then use it in VM
from open-event-attendee-android.
I am a little confused. Can't we directly use it in VM?
I don't see many components that can be added to the VM from this class.
AFAIK we can only add components which do not depend on context,activity etc
So what I was thinking of doing was declaring the variables in the VM and accessing them from the fragment. Is there anything else that can be done ?
from open-event-attendee-android.
Yes, we need to create services and repository or else the same repetitive code like SharedPreferenceUtils,get(TOKEN)
will just get transferred from Activities to ViewModels. In fact it won't be possible without services to create android free VMs
VMs are glue logic, they use Models, models should be the components to contain logic, not ViewModel. ViewModel should just bind models and views. This is by definition explanation of VMs
Look at Orga App code for example
from open-event-attendee-android.
Also, this is not true that you can only add logic which does not depend on Android in ViewModels, this entire notion is the reason there are half-baked MV* apps out there. You create components which encapsulate the logic separate from activities and use them in VMs
There needs to be no code in Activities other than view UI logic
from open-event-attendee-android.
@iamareebjamal I was also going to start working on Parent issue #21, just wanted to confirm that by Orga App you mean MVP architecture? they are using presenter classes
Please correct me if I am wrong 👍
from open-event-attendee-android.
I wanted to address the architecture beyond MVP and MVVM. What you use in presentation logic is irrelevant to the underlying architecture. It's just a pattern. Real abstraction and encapsulation happens in models which are common in both
MVP
authModel.login()
.subscribe(result -> view.onResult(result)
MVVM
fun login() = authModel.login()
There's practically no difference. The real effort and elegance lies in creation of AuthModel. Your presenters and ViewModels should be clean as well or you'll just change God Acticities to God ViewModels. Follow SOLID and have only binding and glue logic in the ViewModels. The ViewModels should look like you're using an elegant library with nice API when querying the models, hence holding all logic in isolated components
from open-event-attendee-android.
Look at Orga App on how the underlying architecture has been implemented. You don't have to clone the architecture, make it even better and cleaner
from open-event-attendee-android.
@iamareebjamal seeing this article https://developer.android.com/jetpack/docs/guide
I think we have to add a repository layer along with the viewModel. Similar to how it is being done here ?
from open-event-attendee-android.
Yup. But no need to add Resource and other jargon. Just isolate the logic in it. Right now I'm working on structuring the project. Continue on this once I have pushed. Work on features and other issues for now
from open-event-attendee-android.
Related Issues (20)
- bug(UI): margins in search filters
- Add "settings button" and "skip for now" on login screen
- bug: No scrolling in past tickets filter HOT 3
- Layout of "Sign in to like event"
- bug: Unable to scroll upload profile pic dialog
- Edit Profile Force Close HOT 3
- Doesn't work mobile check in HOT 1
- Integrate Circle CI to automate the APK build HOT 5
- A UI glitch that happens in the events fragment when refreshed.
- Shows empty message before the items are fetched in favourite fragment.
- Add a dialog notifying that the app is prototype HOT 4
- Issue in the Tickets Fragment when there is no internet.
- In search activity, layout problem in dark mode(some Text view is missing, see screen shot) HOT 3
- Payment gateway HOT 1
- A display bug HOT 1
- A display bug on search HOT 3
- SnackBar showing incomprehensible pop out message in the EventDetails Fragment. HOT 2
- Issue with Orientation and displaying Data HOT 1
- Implement schedule and personal schedule
- Simplify App HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from open-event-attendee-android.