import { Injectable } from '@angular/core' ; import { BehaviorSubject , Observable } from "rxjs" ; @ Injectable ( { providedIn : 'root' } ) export class CurrentAccountService { private _currentAddress : BehaviorSubject < string > = new BehaviorSubject < string > ( null ) ; constructor ( ) { } public get currentAddress ( ) : Observable < string > { return this . _currentAddress . asObservable ( ) ; } public get address ( ) : string { return this . _currentAddress . value ; } public set address ( value ) { this . _currentAddress . next ( value ) ; } public hasActiveAddress ( ) { return ! ! this . _currentAddress . value ; } public clearAddress ( ) { this . _currentAddress . next ( null ) ; } }