Created
          September 23, 2021 06:32 
        
      - 
      
 - 
        
Save Komock/142c9c919a19a4d11848278f4d4c2d8c to your computer and use it in GitHub Desktop.  
    View state from BehaviorSubject
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | export class ViewState<T extends object> extends BehaviorSubject<T> { | |
| constructor(initialState: T) { | |
| super(initialState); | |
| } | |
| patch(newState: Partial<T>) { | |
| this.next({ | |
| ...this.value, | |
| ...newState | |
| }); | |
| } | |
| set(newState: T) { | |
| this.next(newState); | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment