Skip to main content

SubscribePort

Type Alias SubscribePort 

Source
pub type SubscribePort<T> = Port<dyn SinkHandle<T>>;
Expand description

A port that receives broadcast items. It is the odd one out: instead of the export writing an interface into it, the component fills it with its subscriber (subscribe) and the hub reads it out at connect time. Broadcast runs the other way, so the wiring does too.

Aliased Type§

pub struct SubscribePort<T> { /* private fields */ }

Implementations§

Source§

impl<T: 'static> SubscribePort<T>

Source

pub fn subscribe<S: Subscriber<T>>(&self, subscriber: RustdvShared<S>)

Supply the receiver: hand the port a handle to the subscriber whose write should run for every item.

Called in the subscriber’s build, before any connect phase runs, so it is already in place when the hub comes looking for it. connect chooses the stream; subscribe supplies the receiver.

Source

pub fn subscriber(&self) -> Option<Rc<dyn SinkHandle<T>>>

The subscriber this port was given, if subscribe was called.