当前位置: 首页>>代码示例>>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;未经允许,请勿转载。