Open sirvon opened 9 years ago
Good find, at first glance it looks good. I'll check it out.
@sirvon Hey sirvon I'm in the middle of working with the library which is quite powerful, and requires some care with its usage, else you can mess up the ordering of the thread calls. Have you had a chance to work with it? Thoughts?
honestly, its the only solution of the th four major ones, I've found to improve async flow. But as you said you have to take care to receive results, which I don't like in its design.
It's messing up the architecture in my mind with regards to Mixpanel and Event/Analytic calling.
I use it mostly to call methods I don't need a result on the android/client side but receive the results server side.
package com.loqooapps.Services;
import com.joanzapata.android.asyncservice.api.annotation.AsyncService;
import com.loqooapps.BuildConfig;
import net.gpedro.integrations.slack.SlackApi;
import net.gpedro.integrations.slack.SlackMessage;
/**
* Created by creator on 8/20/15.
*/
@AsyncService
public class SlackService {
public void sendSlackMsg(String msg){
SlackApi api = new SlackApi(BuildConfig.SLACK_BASE_URL+BuildConfig.SLACK_ERROR_CHANNEL_WEBHOOK);
api.call(new SlackMessage(msg));
}
public void requestClientToken(String msg){
SlackApi api = new SlackApi(BuildConfig.SLACK_BASE_URL+BuildConfig.SLACK_XNA_INFRA_WEBHOOK);
api.call(new SlackMessage(msg));
}
}
@InjectService
public SlackService slackService;
slackService.requestClientToken(BuildConfig.REQUEST_CLIENT_TOKEN + "......." + subdata + "......");
I haven't used it with POJOs and probably wont.
It's very good to get Dagger Injections into those Services. I really would like to get all my initializations async'd instead of on the app class.
About thread ordering what are you referring to, can you show an example?
I'm scheming on setting up one of these:
https://github.com/stanfy/goro https://github.com/boxme/AsyncManager
https://github.com/KenerChang/AndroidLooperThread
But I instinctively feel Rx style is the best option, I use that as well to receive alot of incoming data and its flawless but I haven't gotten in down pack to just execute a method from rx in the background, simply. Like what's being done here.
comes with time and learning the many styles...i guess.
Ok, I'm seeing the use-case in your example. The thread ordering is with regards to:
@OnMessage(from = ALL)
/* instead of the default, having lots of receivers in other classes may cause
race conditions pending on how you integrate your call logic (clearly
defining logical boundaries allowing for asynchronous access by using
immutable data, thread safe data structures) */
For time effectiveness I agree with Rx as a consideration, with libraries I try to select them pending on which provides a generalized solution for common use-cases.
https://github.com/JoanZapata/android-asyncservice