title: Angular : remove item from BehaviorSubject<any[]>([])
body: <p>This is a little data service in my Angular5 app.
  I am trying to add/remove item from an array (actually a BehaviorSubject).</p>
  
  <p><code>data.service.ts</code></p>
  
  <pre><code>private roomArr_source = new BehaviorSubject&lt;any[]&gt;([]);
  current_roomArr = this.roomArr_source.asObservable();
  
  addRoomArr(data: any) {
      this.roomArr_source.next(this.roomArr_source.getValue().concat([data]));
  }
  
  removeRoomArr(data: any) {
      this.roomArr_source.forEach((item, index) =&gt; {
          if(item === data) { this.roomArr_source.splice(index, 1); }
      });
  }
  </code></pre>
  
  <p>The addRoomArr functions works, but not the removeRommArr.
  Error is :</p>
  
  <pre><code>error TS2345: Argument of type '(item: any, index: any) =&gt; void' is not assignable to parameter of type '(value: any[]) =&gt; void'.
  error TS2339: Property 'splice' does not exist on type 'BehaviorSubject&lt;any[]&gt;'.
  </code></pre>
  
  <p>Somehow I have to convert my BehaviorSubject into an array so that I can use .forEach().
  How can i manage to do that ?</p>
  
  <p>Thanks</p>