I am learning Angular 2 and RxJS at the moment and feel that this is probably the simplest question there is. I am using the Store to save 'users' to. I want to test to see if this is empty or not from the Typescript side rather than in the Angular template.
Below are the pertinent lines of code.
public users: Observable<User[]>;
public store: Store<AppState>;
this.users = this.store.select(state => state.user);
if(!this.users) {
//DO THIS
}
I have tried length, == null, == undefined and can't find how to test for this seemingly basic state. Any help appreciated.
Note that saving and retrieving users to the store is working correctly.
if(!this.users) .... It should bethis.users.subscribe(users => { if (!users.length) ... }).