title: IONIC Angular TypeScript -> How to use RxJs BehaviorSubject inside Service with an Observable
body: <p><strong>What I want to do?</strong>
  An application with Bluetooth data transfer where, in a Service that provide this communication to multiples components, I implement RxJs BehaviorSubject to provide Bluetooth status signaling (just enable, disable and paired, numbers) to other component (a header) that change a Bluetooth icon.
  I need to share the transferred data also, but is the same issue.</p>
  <p><strong>What works?</strong>
  The RxJs BehaviorSubject can pass the data to the Icon component if I use it in a Service method implementing a Set method in the source (Bluetooth Service) and a subscribe in the receiver component (header).</p>
  <p><strong>The Problem:</strong>
  The Bluetooth API use an Observable to connect and provide the transfered data that works fine with a console.log, but it didn't work if I try to use a BehaviorSubject Set method to pass data to others components.</p>
  <p><strong>The -&gt; Service bluethootService.ts:</strong></p>
  <pre><code>import { Injectable } from '@angular/core';
    import { BluetoothSerial } from '@ionic-native/bluetooth-serial/ngx'; //https://github.com/don/BluetoothSerial
    import { BehaviorSubject } from 'rxjs';
  
  
  @Injectable({
    providedIn: 'root'
  })
  export class BluetootConnService {
  
    constructor(private bluetoothSerial: BluetoothSerial) {}
  
    //Bluetooth data Observer
    private btDataSubject = new BehaviorSubject&lt;string&gt;('');
    cuBTData= this.btDataSubject.asObservable();
  
    setBTData(btData: string): void {
        this.btDataSubject.next(btData);
    }
  
    //Bluetooth Indicator
    private btIndicatorSubject = new BehaviorSubject&lt;number&gt;(0);
    cuBTIndicator= this.btIndicatorSubject.asObservable();
  
    setBTIndicator(status: number): void {
        this.btIndicatorSubject.next(status);
    }
  
    
  
    connection(address: string) {
      // Attempt to connect device with specified address, call app.deviceConnected if success
      this.bluetoothSerial.connect(address).subscribe(success =&gt; {
        this.deviceConnected();
        this.setBTIndicator(2); &lt;------- Didn't Work ------------
        console.log(&quot;Successfully Connected&quot;);
  
      }, error =&gt; {
        this.setBTIndicator(1); &lt;------- Didn't Work ------------
        console.log(&quot;Connection Error&quot; +  error);
      });
    }
  
    deviceConnected() {
      // Subscribe to data receiving as soon as the delimiter is read
      this.bluetoothSerial.subscribe('\n').subscribe(serialData =&gt; {
        this.setBTData(serialData); &lt;------- Didn't Work ------------
      }, error =&gt; {
        console.log(error);
      });
    }
  
  
  }
  </code></pre>
  <p><strong>Where I use the Bluetooth Service:</strong></p>
  <pre><code>import { Component, OnInit,NgZone } from '@angular/core';
  import { LoadingController } from '@ionic/angular';
  import { AlertController } from '@ionic/angular';
  import { OpenNativeSettings } from '@ionic-native/open-native-settings/ngx';
  import { ShareddataService } from '../services/shareddata.service';
  import { BluetootConnService } from '../services/bluetoot-conn.service'
  
  
  @Component({
    selector: 'app-bluetooth',
    templateUrl: './bluetooth.page.html',
    styleUrls: ['./bluetooth.page.scss'],
  })
  export class BluetoothPage implements OnInit {
  
    thisPageName = &quot;Dispositivos&quot;;
  
    constructor(
      public alertCtrl: AlertController,
      private openNativeSettings: OpenNativeSettings,
      private ShareddataService: ShareddataService,
      private bluetootConnService: BluetootConnService,
      public toastController: ToastController,
      private zone: NgZone
    ) { }
  
  
  
    devicesList = [];
    connectedId:string;
  
  
  
    async ItemSelected(selectedId:string) {
  
      console.log('Previou Connected ID:' + this.connectedId);
      if (selectedId == this.connectedId){this.Toast('Éste módulo ya está conectado'); return;}
  
  
      const connectingWait = await this.loadingController.create({
        message: 'Conectando...',
      });
      await connectingWait.present();
  
      console.log('Conecting to: ' + selectedId);
  
      await this.bluetootConnService.connection(selectedId); &lt;------- Here!----------
  
      connectingWait.dismiss();
    }
  
  }
  </code></pre>
  <p><strong>The Header -&gt; component pagesHeaderComponet.ts:</strong></p>
  <pre><code>import { Component, OnInit, Input } from '@angular/core';
  import { BluetootConnService } from '../../services/bluetoot-conn.service'
  
  
  @Component({
    selector: 'PagesHeaderComponent',
    templateUrl: './pages-header.component.html',
    styleUrls: ['./pages-header.component.scss'],
  })
  export class PagesHeaderComponent implements OnInit {
  
    @Input()pageName;
  
    ourMessage:string;
    btStatus:number; //0: Disable / 1: Enable / 2: Connected
  
    constructor(private ShareddataService: ShareddataService, private bluetootConnService: BluetootConnService,) { }
  
    ngOnInit() {
      this.bluetootConnService.cuBTIndicator.subscribe(data =&gt; this.btStatus = data);
    }
  
  }
  </code></pre>
  <p><strong>Summarizing:</strong>
  How can I share data from inside an Observable to other modules?</p>
  <p>Thank you in advance.
  Best Regards!</p>