All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dragome.forms.bindings.client.command.DelegatingAsyncEvents Maven / Gradle / Ivy

There is a newer version: 0.96-beta4
Show newest version
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();
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy