Skip to main content

ValueDispatcher

                            
                              
                                class 
                                ValueDispatcher
                                
                                  
                                    
                                      T
                                    
                                  
                                
                                extends 
                                
                                  
                                    
                                      EventDispatcherBase
                                      
                                        
                                          
                                            T
                                          
                                        
                                      
                                    
                                  
                                
                              
                              

Dispatches a SubscribableValueEvent

Changing the value stored by a value dispatcher will immediately notify allits subscribers.

Examples

Type Parameters

  • T

    The type of the value passed to subscribers.

Constructors

constructor

                            
                              
                                public 
                                override
                                new
                                ValueDispatcher
                                
                                  
                                    
                                      T
                                    
                                  
                                
                                
                                  
                                    
                                      value
                                      : 
                                      T
                                    
                                  
                                
                                : 
                                ValueDispatcher
                                
                                  
                                    
                                      T
                                    
                                  
                                
                              
                              

Type Parameters

Parameters

  • value : T

    The initial value.

Overwrites EventDispatcherBase.constructor

Properties

subscribable

                            
                              
                                readonly 
                                public 
                                subscribable
                                : 
                                SubscribableValueEvent
                                
                                  
                                    
                                      T
                                    
                                  
                                
                                 = 
                                ...
                              
                              

Accessors

current

                            
                              
                                public 
                                set 
                                current
                                
                                  
                                    
                                      value
                                      : 
                                      T
                                    
                                  
                                
                                : 
                                void
                              
                              
                            
                              
                                public 
                                get 
                                current
                                (): 
                                T
                              
                              

Set the current value of this dispatcher.

Setting the value will immediately notify all subscribers.

Parameters

  • value : T

    The new value.

Methods

clear

                            
                              
                                public 
                                clear
                                (): 
                                void
                              
                              

Unsubscribe all subscribers from the event.

Inherited from EventDispatcherBase.clear

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 EventDispatcherBase.subscribe

unsubscribe

                            
                              
                                public 
                                unsubscribe
                                
                                  
                                    
                                      handler
                                      : 
                                      EventHandler
                                      
                                        
                                          
                                            T
                                          
                                        
                                      
                                    
                                  
                                
                                : 
                                void
                              
                              

Unsubscribe from the event.

Parameters

  • handler : EventHandler T

    The handler to unsubscribe.

Inherited from EventDispatcherBase.unsubscribe