com.dragome.forms.bindings.client.command.DelegatingAsyncEvents Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dragome-form-bindings Show documentation
Show all versions of dragome-form-bindings Show documentation
Dragome SDK module: form bindings
package com.dragome.forms.bindings.client.command;
import com.dragome.forms.bindings.client.binding.Disposable;
/**
* Created by IntelliJ IDEA.
* User: andrew
* Date: Mar 21, 2010
* Time: 3:20:07 PM
* To change this template use File | Settings | File Templates.
*/
public class DelegatingAsyncEvents extends AsyncEventsImpl implements Disposable
{
private Disposable disposable;
private AsyncLifeCycleCallback callback= new DelegateCallback();
public DelegatingAsyncEvents()
{
}
public DelegatingAsyncEvents(AsyncEvents source)
{
setDelegate(source);
}
public void setDelegate(AsyncEvents source)
{
if (disposable != null)
{
disposable.dispose();
disposable= null;
}
if (source != null)
{
disposable= source.sendAllEventsTo(callback);
}
}
public void dispose()
{
setDelegate(null);
}
private class DelegateCallback implements AsyncLifeCycleCallback
{
public void onStart()
{
fireStart();
}
public void onSuccess(R result)
{
fireSuccess(result);
}
public void onError(E error)
{
fireError(error);
}
public void onFinish()
{
fireFinish();
}
}
}