/// Take a channel Sender that you can send subscriber id's to to unsubscribe to at any time.
/// This will spawn a task that listens to this channel to update our subscribers
/// list as needed. When this `PubSub` get's dropped or you drop the sender,
/// that task will be canceled and dropped.
//
Take a channel Sender that you can send subscriber id's to to unsubscribe to at any time.
This will spawn a task that listens to this channel to update our subscribers
list as needed. When this `PubSub` get's dropped or you drop the sender,
that task will be canceled and dropped.
Take a channel Sender that you can send subscriber id ' s to to unsubscribe to at any time . This will spawn a task that listens to this channel to update our subscribers list as needed . When this ` PubSub ` get ' s dropped or you drop the sender that task will be canceled and dropped .
pub fn rt_unsubscribe( &mut self, exec: &impl SpawnHandle<()> )
		-> Result< futUnboundSender< usize >, PeerErr >
	{
		assert!( self.rt_unsub.is_none(), "Can only call rt_subscribe once. Clone the Sender if you need it in several places." );
		let (tx, mut rx) = mpsc::unbounded::<usize>();
		let map          = self.subscribers.clone();
		let task = async move
		{
			while let Some(sub) = rx.next().await
			{
				let mut m = map.lock();
				m.remove( &sub );
			}
		};
		self.rt_unsub = Some
		(
			exec.spawn_handle(task)
			.map_err( |_| PeerErr::Spawn{ ctx: PeerErrCtx::default().context( "PubSub".to_string() ) } )?
		);
		Ok(tx)
	}
pub fn rt_unsubscribe ( & mut self , exec : & impl SpawnHandle < ( ) > ) -> Result < futUnboundSender < usize > , PeerErr > { assert ! ( self rt_unsub is_none ( ) " " ) ; let ( tx , mut rx ) = mpsc :: unbounded :: < usize > ( ) ; let map = self . subscribers . clone ( ) ; let task = async move { while let Some ( sub ) = rx . next ( ) . await { let mut m = map . lock ( ) ; m . remove ( & sub ) ; } } ; self . rt_unsub = Some ( exec . spawn_handle ( task ) . map_err ( | _ | PeerErr :: Spawn { ctx : PeerErrCtx :: default ( ) . context ( " " . to_string ( ) ) } ) ? ) ; Ok ( tx ) }
Take a channel Sender that you can send subscriber id's to to unsubscribe to at any time.
Take a channel Sender that you can send subscriber id ' s to to unsubscribe to at any time .
&mut self
exec
&impl SpawnHandle<()>