Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What about service and broadcast? #95

Open
Melonpi opened this issue Jun 8, 2016 · 3 comments
Open

What about service and broadcast? #95

Melonpi opened this issue Jun 8, 2016 · 3 comments
Labels

Comments

@Melonpi
Copy link

Melonpi commented Jun 8, 2016

I've seen some MVP implementations, but no one talks about long running service(e.g. media player) and system broadcast.
They are created with context, so they should be placed in model layer or something?
Is there any reference we can get?
And thanks for your great work, this repo is so helpful.

@Juude
Copy link

Juude commented Jun 15, 2016

for broadcast
when we talk about MVP, that does not mean that there are only M, V, and P in the code. we also need to communicate between the three layers, in this code repository, we use interface to communicate, but we can also use broadcast and otto to communicate between different layers.

for service
Because service has no ui, we often use Service as the P and M, for example in a audio player, we use a Service to listen to UI actions and play/pause the music, we also use Service to access our playlists that is Model.

@Melonpi
Copy link
Author

Melonpi commented Jun 18, 2016

Thanks for your reply.
I think most question is about classes need a context and lifecycle always binding to an activity.

For broadcast
sry for the misleading, I mean system broadcast and broadcast receivers with context.
Rxbus or otto may be a good choice. For system broadcast receiver, make it just as a publisher for system broadcast may be a good practice.
So it can be hold directly by activity or presenter,and make tests in presenter by mock events?

For service
Presenters is mean to has no aware of context to make test easier. But as you said, service be a presenter may also contains so business logic, maybe there should be one more layer?
A service control audio player and also saving/loading data may be too heavy.

One more thing, do u have any occasion to let one view has multi presenters?

@ghost
Copy link

ghost commented Jul 5, 2016

Why don't we create s new architecture for these needs , #115

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants