我正在做我的应用程序搜索系统。我订阅的EventBusEvent我怎样才能订阅只有最后的数据?
addSubscription(TheApplication.getEventBus().observe(UpdateSearchResults.class).subscribe(event ->
getViewModel().setParameter(event.getText())
));
事件:
public class UpdateSearchResults
{
public UpdateSearchResults(String text)
{
this.text = text;
}
public String getText()
{
return text;
}
private String text;
}
而每一次,当用户输入新的符号。我发送这样的事件:
TheApplication.getEventBus().post(new UpdateSearchResults(newText));
我可以帮助rxJava只处理最后的数据吗?
例如:用户输入字符串fast:“示例”后输入符号“e”订阅将起作用。但对于其他符号订阅不起作用。
问题存在哪些解决方案?
@tynn我不知道。也许有一些RX功能在其中发送时间段,并且当订阅者的时间段结束时会落入最后发送的事件 –