To handle the no-initial-items scenario, you could just put an *ngIf="this.items?.length" on your <p-tabView> element.
To handle both the no-initial-items and the one-initial-item scenarios, you could use the activeIndex property of <p-tabView>:
<p-tabView [activeIndex]="activeIndex"> <----- add [activeIndex] here
<p-tabPanel *ngFor="let item of items; let i = index" [header]="item.username" [selected]="i == 0">
[{{item.username}}]
</p-tabPanel>
</p-tabView>
Setting that value after your data has arrived will trigger <p-tabView> to refresh itself.
So your component would look like this:
items = [
{ username: "INITIAL"}
];
activeIndex: number; // <--- declare but don't initialize
constructor(private http: HttpClient) {}
ngOnInit(): void {
const source = this.get$();
const subscribe = source.subscribe(result => {
this.items = result.slice(0,3);
this.activeIndex = 0; // <---- set to 0 to trigger p-tabView refresh
});
}
Here's a fork of your StackBlitz demonstrating this approach.