Skip to main content

SubscribableValueEvent

                            
                              
                                class 
                                SubscribableValueEvent
                                
                                  
                                    
                                      T
                                    
                                  
                                
                                extends 
                                
                                  
                                    
                                      Subscribable
                                      
                                        
                                          
                                            T
                                          
                                          
                                            EventHandler
                                            
                                              
                                                
                                                  T
                                                
                                              
                                            
                                          
                                        
                                      
                                    
                                  
                                
                              
                              

Provides safe access to the public interface of ValueDispatcher .

External classes can use it to subscribe to an event without being able todispatch it.

Type Parameters

  • T

    The type of the value passed to subscribers.

Constructors

constructor

                            
                              
                                public 
                                new
                                SubscribableValueEvent
                                
                                  
                                    
                                      T
                                    
                                  
                                
                                
                                  
                                    
                                      dispatcher
                                      : 
                                      EventDispatcherBase
                                      
                                        
                                          
                                            T
                                          
                                          
                                            EventHandler
                                            
                                              
                                                
                                                  T
                                                
                                              
                                            
                                          
                                        
                                      
                                    
                                  
                                
                                : 
                                SubscribableValueEvent
                                
                                  
                                    
                                      T
                                    
                                  
                                
                              
                              

Type Parameters

Parameters

  • dispatcher : EventDispatcherBase T EventHandler T
Inherited from Subscribable.constructor

Accessors

current

                            
                              
                                public 
                                get 
                                current
                                (): 
                                T
                              
                              

Get the most recent value of this dispatcher.

Methods

subscribe

                            
                              
                                public 
                                override
                                subscribe
                                
                                  
                                    
                                      handler
                                      : 
                                      EventHandler
                                      
                                        
                                          
                                            T
                                          
                                        
                                      
                                    
                                    
                                      dispatchImmediately
                                      : 
                                      boolean
                                       = 
                                      true
                                    
                                  
                                
                                : () => 
                                void
                              
                              

Subscribe to the event.

Subscribing will immediately invoke the handler with the most recent value.

Parameters

  • handler : EventHandler T

    The handler to invoke when the event occurs.

  • dispatchImmediately : boolean = true

    Whether the handler should be immediatelyinvoked with the most recent value.

Overwrites Subscribable.subscribe

unsubscribe

                            
                              
                                public 
                                unsubscribe
                                
                                  
                                    
                                      handler
                                      : 
                                      EventHandler
                                      
                                        
                                          
                                            T
                                          
                                        
                                      
                                    
                                  
                                
                                : 
                                void
                              
                              

Unsubscribe from the event.

Parameters

  • handler : EventHandler T

    The handler to unsubscribe.

Inherited from Subscribable.unsubscribe