當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript rxjs.from函數代碼示例

本文整理匯總了TypeScript中rxjs.from函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript from函數的具體用法?TypeScript from怎麽用?TypeScript from使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了from函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: test

test('`setup` registers plugin config schema in config service', async () => {
  const configSchema = schema.string();
  jest.spyOn(configService, 'setSchema').mockImplementation(() => Promise.resolve());
  jest.doMock(
    join('path-with-schema', 'server'),
    () => ({
      config: {
        schema: configSchema,
      },
    }),
    {
      virtual: true,
    }
  );
  mockDiscover.mockReturnValue({
    error$: from([]),
    plugin$: from([
      new PluginWrapper(
        'path-with-schema',
        {
          id: 'some-id',
          version: 'some-version',
          configPath: 'path',
          kibanaVersion: '7.0.0',
          requiredPlugins: [],
          optionalPlugins: [],
          server: true,
          ui: true,
        },
        { logger } as any
      ),
    ]),
  });
  await pluginsService.setup(setupDeps);
  expect(configService.setSchema).toBeCalledWith('path', configSchema);
});
開發者ID:elastic,項目名稱:kibana,代碼行數:36,代碼來源:plugins_service.test.ts

示例2: from

 /**
  * @param url
  * @param data
  * @param config 
  */
 post<T, U = string>(url: string, data?: any, config: AxiosRequestConfig = {}): Observable<IResult<T, U>> {
     return from(axios.post(url, data, config))
             .pipe(
                 map(response => response.data),
                 catchError((error: AxiosResponse | undefined) => {
                     console.log(error);
                     if (error === undefined) {
                         return message.error('請求出錯');
                     }
                     this.error$ = of(error);
                     this.handleError();
                     return this.error$;
                 })
             );
 }
開發者ID:75team,項目名稱:firekylin,代碼行數:20,代碼來源:http.ts

示例3: addProcessInstanceComment

 /**
  * Adds a comment to a process instance.
  * @param processInstanceId ID of the target process instance
  * @param message Text for the comment
  * @returns Details of the comment added
  */
 addProcessInstanceComment(processInstanceId: string, message: string): Observable<CommentModel> {
     return from(
         this.apiService.getInstance().activiti.commentsApi.addProcessInstanceComment({ message: message }, processInstanceId)
     ).pipe(
         map((response: CommentModel) => {
             return new CommentModel({
                 id: response.id,
                 message: response.message,
                 created: response.created,
                 createdBy: response.createdBy
             });
         }),
         catchError((err: any) => this.handleError(err))
     );
 }
開發者ID:Alfresco,項目名稱:alfresco-ng2-components,代碼行數:21,代碼來源:comment-process.service.ts

示例4: from

export function wrapIntoObservable<T>(value: T | NgModuleFactory<T>| Promise<T>| Observable<T>):
    Observable<T> {
  if (isObservable(value)) {
    return value;
  }

  if (isPromise(value)) {
    // Use `Promise.resolve()` to wrap promise-like instances.
    // Required ie when a Resolver returns a AngularJS `$q` promise to correctly trigger the
    // change detection.
    return from(Promise.resolve(value));
  }

  return of (value as T);
}
開發者ID:DeepanParikh,項目名稱:angular,代碼行數:15,代碼來源:collection.ts

示例5: it

  it('should map values to resolved promises and concatenate', (done) => {
    const source = from([4, 3, 2, 1]);
    const project = (value: number, index: number) => Observable.from(Promise.resolve(value + index));

    const results: number[] = [];
    source.concatMap(project).subscribe(
      (x) => {
        results.push(x);
      }, (err) => {
        done(new Error('Subscriber error handler not supposed to be called.'));
      }, () => {
        expect(results).to.deep.equal([4, 4, 4, 4]);
        done();
      });
  });
開發者ID:MykhailoIskiv,項目名稱:rxjs,代碼行數:15,代碼來源:concatMap-spec.ts

示例6: getProcessInstances

 /**
  * Gets process instances for a filter and optionally a process definition.
  * @param requestNode Filter for instances
  * @param processDefinitionKey Limits returned instances to a process definition
  * @returns List of process instances
  */
 getProcessInstances(requestNode: ProcessFilterParamRepresentationModel, processDefinitionKey?: string): Observable<ProcessListModel> {
     return from(this.alfrescoApiService.getInstance().activiti.processApi.getProcessInstances(requestNode))
         .pipe(
             map((res: any) => {
                 if (processDefinitionKey) {
                     const filtered = res.data.filter((process) => process.processDefinitionKey === processDefinitionKey);
                     res.data = filtered;
                     return res;
                 } else {
                     return res;
                 }
             }),
             catchError((err) => this.handleProcessError(err))
         );
 }
開發者ID:Alfresco,項目名稱:alfresco-ng2-components,代碼行數:21,代碼來源:process.service.ts

示例7: mergeMap

    mergeMap(() => {
      const state = state$.value;

      const contentRef$ = from(
        state.core.entities.contents.byRef
          .filter(
            // Don't bother with non-file and non-notebook types for saving
            // (no dummy or directory)
            content => content.type === "file" || content.type === "notebook"
          )
          .keys()
      );

      return contentRef$;
    }),
開發者ID:nteract,項目名稱:nteract,代碼行數:15,代碼來源:contents.ts

示例8: getNpmPackageJson

export function getNpmPackageJson(
  packageName: string,
  logger: logging.LoggerApi,
  options?: {
    registryUrl?: string;
    usingYarn?: boolean;
    verbose?: boolean;
  },
): Observable<Partial<NpmRepositoryPackageJson>> {
  const cachedResponse = npmPackageJsonCache.get(packageName);
  if (cachedResponse) {
    return cachedResponse;
  }

  if (!npmrc) {
    try {
      npmrc = readOptions(logger, false, options && options.verbose);
    } catch { }

    if (options && options.usingYarn) {
      try {
        npmrc = { ...npmrc, ...readOptions(logger, true, options && options.verbose) };
      } catch { }
    }
  }

  const resultPromise: Promise<NpmRepositoryPackageJson> = pacote.packument(
    packageName,
    {
      'full-metadata': true,
      ...npmrc,
      ...(options && options.registryUrl ? { registry: options.registryUrl } : {}),
    },
  );

  // TODO: find some way to test this
  const response = from(resultPromise).pipe(
    shareReplay(),
    catchError(err => {
      logger.warn(err.message || err);

      return EMPTY;
    }),
  );
  npmPackageJsonCache.set(packageName, response);

  return response;
}
開發者ID:angular,項目名稱:angular-cli,代碼行數:48,代碼來源:npm.ts

示例9: findGroupsByName

    /**
     * Finds groups filtered by name.
     * @param searchParams Object containing the name filter string
     * @returns List of group information
     */
    findGroupsByName(searchParams: GroupSearchParam): Observable<any> {
        if (searchParams.name === '') {
            return of([]);
        }
        const url = this.getGroupsApi();
        const httpMethod = 'GET', pathParams = {}, queryParams = {search: searchParams.name}, bodyParam = {}, headerParams = {},
            formParams = {}, contentTypes = ['application/json'], accepts = ['application/json'];

        return (from(this.apiService.getInstance().oauth2Auth.callCustomApi(
            url, httpMethod, pathParams, queryParams,
            headerParams, formParams, bodyParam,
            contentTypes, accepts, Object, null, null)
        )).pipe(
            catchError((err) => this.handleError(err))
        );
    }
開發者ID:Alfresco,項目名稱:alfresco-ng2-components,代碼行數:21,代碼來源:group-cloud.service.ts

示例10: switchMap

 switchMap(user => {
   if (user) {
     return from(user.getIdToken())
     .pipe(
       switchMap((token) => {
         return next.handle(req.clone({
           setHeaders: {
             Authorization: token
           }
         }));
       })
     );
   } else {
     return next.handle(req);
   }
 })
開發者ID:farleydiaz,項目名稱:farley-test,代碼行數:16,代碼來源:AuthInterceptor.ts


注:本文中的rxjs.from函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。