title: How to subscribe to a normal function as an Observable in Angular
body: <p>I have a function that returns an object.</p>
  
  <pre><code>           getUserState(): UserState {
                return this.userState;
             }
  </code></pre>
  
  <p>I am storing the above function result in an observable as follows:</p>
  
  <pre><code>       username$: Observable&lt;UserState[]&gt;;
  
         constructor(private userService:UserStateService) {}
  
         ngOnInit(): void {
              this.username$ = this.userService.getUserState().map(data =&gt; 
              {
                this.username$ = data;
              }) 
        }
  </code></pre>
  
  <p>Here I am getting the error:</p>
  
  <pre><code>        Property 'map' does not exist on type 'UserState'.
  </code></pre>
  
  <p>What did I do wrong?</p>