import {Component, OnInit} from '@angular/core';
import {UsersService} from './services/users.service';
import {BehaviorSubject} from 'rxjs';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  standalone: false,
  styleUrl: './app.component.css'
})
export class AppComponent implements OnInit {
    // title = 'ufund-ui';
    currentUser$: BehaviorSubject<string> = new BehaviorSubject<string>("Logged out.");

    constructor(
        private userService: UsersService
    ) {}

    ngOnInit() {
        this.userService.getCurrentUserSubject().subscribe(r => {
            this.currentUser$?.next(r
                ? "Logged in as " + r.username
                : "Logged out."
            )
        })
    }

}