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

com.dragome.forms.bindings.client.channel.Channel Maven / Gradle / Ivy

There is a newer version: 0.96-beta4
Show newest version
package com.dragome.forms.bindings.client.channel;

import com.dragome.forms.bindings.client.binding.Disposable;
import com.dragome.forms.bindings.client.command.ParameterisedCommand;
import com.dragome.forms.bindings.client.function.Function;
import com.dragome.forms.bindings.client.value.ValueTarget;
import com.dragome.model.interfaces.HasValue;

/**
 * Channels allow objects to be passed between interested parties.  It's a similar concept to an event bus
 * except that it doesn't require the creation of explicit event types.  On the flips side a single Channel
 * is only suitable for simple notifications, i.e. to notify "customer updated" and "customer deleted" events
 * you'd need two Channel<Customer> instances or a Channel<CustomerEvent>.
 * 

* The {@link #sendTo(Destination)} style methods bind the channel to the specified recipient. */ public interface Channel extends Publisher { Disposable sendTo(Destination destination); Disposable sendTo(Publisher destination); Disposable sendTo(ValueTarget destination); Disposable sendTo(HasValue destination); Disposable sendTo(ParameterisedCommand destination); /** * Returns this Channel as a destination. * @return this Channel as a destination. */ Destination asDestination(); /** * Returns this Channel as a formatted destination. This allows you to convert the * output of one channel into the content for this channel. * *

	 * someChannel.sendTo(thisChannel.formattedWith(myFormat));
	 * 
* * @return this Channel as a formatted destination. */ Destination asFormattedDestination(Function function); /** * Gets a Publisher instance that uses the specified function to convert the published * value into this channels type. *
	 * someChannel.sendTo(thisChannel.usingFormat(myFormat));
	 * 
* @param function the conversion function. * @return a Publisher instance that converts from the source type to this channels type. */ Publisher getFormattedPublisher(Function function); }