【发布时间】:2012-04-16 20:26:01
【问题描述】:
我目前正在开发一个 android 应用程序的表示层。
我使用的 api 看起来像这样:
public interface errorInterface{
public void onError(String reason);
}
public interface if1 extends errorInterface{
public void dataReceived1(Data data);
}
public interface if2 extends errorInterface{
public void dataReceived2(Data data);
}
public void fetchData1(if1 receiver) {}
public void fetchData2(if2 receiver) {}
也就是说;要获取数据,您需要提供一个接收器,该接收器将在未来某个时间接收操作结果。
当您一次只需要调用一个方法时,这非常有效,但现在我已经到了需要一次调用 10+ 个这样的方法,并且它们需要一次执行一个的地步。
如何以灵活优雅的方式解决这个问题?
谢谢!
【问题讨论】:
标签: java design-patterns asynchronous