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


TypeScript operators.expand函數代碼示例

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


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

示例1: expand1

 expand1() {
   // emit 2
   const source = of(2);
   const example = source.pipe(
     // recursively call supplied function
     expand(val => {
       // 2,3,4,5,6
       console.log(`Passed value: ${val}`);
       // 3,4,5,6
       return of(1 + val);
     }),
     // call 5 times
     take(5)
   );
   /*
   	"RESULT: 2"
   	"Passed value: 2"
   	"RESULT: 3"
   	"Passed value: 3"
   	"RESULT: 4"
   	"Passed value: 4"
   	"RESULT: 5"
   	"Passed value: 5"
   	"RESULT: 6"
   	"Passed value: 6"
   */
   // output: 2,3,4,5,6
   const subscribe = example.subscribe(val => console.log(`RESULT: ${val}`));
 }
開發者ID:zwvista,項目名稱:SampleMisc,代碼行數:29,代碼來源:transforming.service.ts

示例2: higherOrder

export function expand<T, R>(this: Observable<T>, project: (value: T, index: number) => ObservableInput<R>,
                             concurrent: number = Number.POSITIVE_INFINITY,
                             scheduler: SchedulerLike = undefined): Observable<R> {
  concurrent = (concurrent || 0) < 1 ? Number.POSITIVE_INFINITY : concurrent;

  return higherOrder(project, concurrent, scheduler)(this);
}
開發者ID:DallanQ,項目名稱:rxjs,代碼行數:7,代碼來源:expand.ts

示例3: expand

 observable1 = expandZone1.run(() => {
   return observable1.pipe(
       expand((val: any) => {
         expect(Zone.current.name).toEqual(expandZone1.name);
         return of(1 + val);
       }),
       take(2));
 });
開發者ID:angular,項目名稱:zone.js,代碼行數:8,代碼來源:rxjs.Observable.merge.spec.ts

示例4: pollBuildProgress

 private pollBuildProgress(locatorType: string, locator: string, minRevision: number): Observable<ProgressStatus> {
   return this.getBuildProgress(locatorType, locator, minRevision).pipe(
     expand(buildDto => {
       if (buildDto != null) {
         locatorType = 'id';
         locator = buildDto.id;
         minRevision = buildDto.revision + 1;
       }
       return this.getBuildProgress(locatorType, locator, minRevision);
     }),
     filter(buildDto => buildDto != null),
     map(buildDto => buildDto as BuildDto),
     takeWhileInclusive(buildDto => buildDto.state === BuildStates.Pending || buildDto.state === BuildStates.Active)
   );
 }
開發者ID:sillsdev,項目名稱:machine,代碼行數:15,代碼來源:web-api-client.ts

示例5: it

it('should infer correctly with a different type as the source', () => {
  const o = of(1, 2, 3).pipe(expand(value => of('foo'))); // $ExpectType Observable<string>
  const p = of(1, 2, 3).pipe(expand(value => ['foo'])); // $ExpectType Observable<string>
  const q = of(1, 2, 3).pipe(expand(value => Promise.resolve('foo'))); // $ExpectType Observable<string>
});
開發者ID:jaychsu,項目名稱:RxJS,代碼行數:5,代碼來源:expand-spec.ts


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