Ionic Observable returning immediatly

Hi all.

I’m having a bit of an issue with an Observable seen below:

  private ConfirmAuthenticationAvailable()
    if (this.registerCredentials.logID === null || this.registerCredentials.password === null) {
      return Observable.throw("Please insert credentials");
    } else {
      console.log("got to here")
      return Observable.create(observer => {
      console.log("got to can't get to here")

          name: 'ionicdb.db',
          location: 'default'
        }).then((db: SQLiteObject) => {

          db.executeSql('SELECT * FROM users;', {})
            .then((resUsersLoaded) => {
              this.userSelection = resUsersLoaded;
              for (let i = 0; i < resUsersLoaded.rows.length; i++) {
                let item = resUsersLoaded.rows.item(i);
          }).catch(e => console.log(e));

        ).catch(e => console.log(e));

       // this.currentUser = new User('ename', '');;


In debugging the code (and watching for the console outputs) the code appears to return immediatly at:
return Observable.create(observer => {

I’m I structuring this in an inappropriate way that would cause this to happen? I’m coming up short looking at the documentation and the source I’m working from.

(sorry for the ugly code otherwise, it’s part of a WIP…)

I can’t speak to “inappropriate”, but I find this both really hard to read and an exercise in futility. You can’t do authentication on device; it must be done on a server that you control. That sort of moots the rest of the discussion, but it is really rare that you would need or want to be creating Observables manually.

Fair enough. it’s just a placeholder for now until I get to that stage. I’ll have to do more reading - thanks!

Unfortunately that choice of placeholder is forcing you to deal with impedance mismatch between Promises and Observables that you won’t have to worry about once you do get to the stage of doing this over HTTP, because HttpClient is already going to be giving you an Observable to work with.