How to use the @reactivex/rxjs.Observable.fromPromise function in @reactivex/rxjs

To help you get started, we’ve selected a few @reactivex/rxjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github machinelabs / machinelabs / server / src / ml-firebase / auth.service.ts View on Github external
authenticate(): Observable {
    if (!this.login$) {
      this.login$ = Observable.fromPromise(new Promise(resolve => firebase.auth().onAuthStateChanged(resolve))
                                .then(user => user ? user : firebase.auth()
                                                                    .signInWithEmailAndPassword(
                                                                      Config.getEnv(Config.ENV_USERNAME),
                                                                      Config.getEnv(Config.ENV_PASSWORD)
                                                                    ))
                              )
                              .publishLast()
                              .refCount();
    }

    return this.login$;
  }
}
github sourcegraph / javascript-typescript-langserver / src / typescript-service.ts View on Github external
textDocumentRename(params: RenameParams, span = new Span()): Observable {
		const uri = normalizeUri(params.textDocument.uri);
		const editUris = new Set();
		return Observable.fromPromise(this.projectManager.ensureOwnFiles(span))
			.mergeMap(() => {

				const filePath = uri2path(uri);
				const configuration = this.projectManager.getParentConfiguration(params.textDocument.uri);
				if (!configuration) {
					throw new Error(`tsconfig.json not found for ${filePath}`);
				}
				configuration.ensureAllFiles(span);

				const sourceFile = this._getSourceFile(configuration, filePath, span);
				if (!sourceFile) {
					throw new Error(`Expected source file ${filePath} to exist in configuration`);
				}

				const position = ts.getPositionOfLineAndCharacter(sourceFile, params.position.line, params.position.character);
github fuse-box / fuse-box / bin / changelog / changelog.ts View on Github external
public get milestones(): Observable {
      const options = this._assignOwnerRepo({
          state: 'closed'
      });
      return Observable.fromPromise(this.github.issues.getMilestones(options))
        .map((resp: any) => resp.data);
  }
   /**
github fuse-box / fuse-box / bin / changelog / changelog.ts View on Github external
public getIssuesByMileStone(milestone): Observable<{milestone:IMilestones.RootObject, issue?: IIssue.RootObject, error?: any }> {
      const options: Github.IssuesGetForRepoParams = this._assignOwnerRepo({
          milestone: milestone.number,
          direction: 'asc',
          state: 'closed'
      });
      return Observable.fromPromise(this.github.issues.getForRepo(options).catch((e) => Promise.reject({milestone: milestone, error: e})))
        .map((resp: any) => {
            return {milestone: milestone, issues: resp.data}
        });
  }
}
github fuse-box / fuse-box / bin / changelog / changelog.ts View on Github external
public getMilestone(id): Observable {
      const options = this._assignOwnerRepo({
          number: id
      });
      return Observable.fromPromise(this.github.issues.getMilestone(options))
        .map((resp: any) => resp.data);
  }
    /**