当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript rxjs.Observable类代码示例

本文整理汇总了TypeScript中@reactivex/rxjs.Observable的典型用法代码示例。如果您正苦于以下问题:TypeScript Observable类的具体用法?TypeScript Observable怎么用?TypeScript Observable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Observable类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1:

 (data) => {
     return Rx.Observable.of({
         target: target,
         data: data,
         fileName: file.name
     });
 }
开发者ID:czcorpus,项目名称:kontext,代码行数:7,代码来源:form.ts

示例2: Post

 () => {
   console.log('Users are saved!');
   const postPromises = posts.map(post => {
     const {userId, title, body} = post;
     return User.findOne({id: userId})
       .then(user => {
         const newPost = new Post({title, body, _creator: user._id});
         return newPost.save();
       })
       .then(newPost => {
         const postCommentsIndex = i + 10;
         for (i; i < postCommentsIndex && i < last; i++) {
           const {body, email} = comments[i];
           let newComment = new Comment({_post: newPost._id, body, email});
           return newComment.save();
         }
       });
   });
   let counter = 0;
   Rx.Observable
     .forkJoin(postPromises)
     .subscribe(
       () => null,
       (err) => console.log(`Err: ${err}`),
       () => {
         console.log('DB population is completed!');
         process.exit();
       }
     );
 }
开发者ID:malaman,项目名称:other,代码行数:30,代码来源:pupulateDB.ts

示例3: to

  to(exchange: string, iO: Observable<any>): Subscription<any> {
    let channel, conn, cachedItems = [];
    let queue = uuid.v4();

    connect(this.config.connString)
    .then(c => conn = c && c.createChannel())
    .then(c => {
      channel = c;

      channel.assertExchange(exchange, 'fanout');
      cachedItems.forEach(item => {
        channel.publish(exchange, '', new Buffer(item));
      });
    })
    .catch(err => { throw err; });

    return iO
      .subscribe(
        msg => {
          if (!channel) {
            return cachedItems.push(msg);
          }

          channel.publish(exchange, '', new Buffer(msg));
        },
        err => console.error(`rabbitSink err, queue: ${queue}`, err),
        () => {
          if (conn) {
            channel.publish(exchange, '', new Buffer('__done'));
            conn.close()
          }
        }
      );
  }
开发者ID:jonesnc,项目名称:gustav,代码行数:34,代码来源:GustavRabbit.ts

示例4: init

function init(state_: string, current_: number) {
  console.log('new');
  return Observable.fromPromise(new Promise((resolve, reject) => {
    setTimeout(() => {
      resolve('init success');
    }, 2000);
  }));
}
开发者ID:taochunyu,项目名称:learn,代码行数:8,代码来源:delay1.ts

示例5:

            this.action$ = this.inStream$.flatMap(v => {
                if (v instanceof Rx.Observable) {
                    return v;

                } else {
                    return Rx.Observable.from([v]);
                }
            }).share();
开发者ID:tomachalek,项目名称:kontext,代码行数:8,代码来源:dispatcher.ts

示例6:

 .mergeMap(() => {
   return Rx.Observable.fromEvent($('.more'), 'click')
     .do((e)=>{
       const target = $(e.currentTarget)
       console.log(target.text(), path)
       location.href=(path + 'more/' + target.text())
     })
 })
开发者ID:gatinul,项目名称:blog,代码行数:8,代码来源:blogList.ts

示例7: newValidationStatus

 (resp) => {
     const ans = newValidationStatus();
     ans.currPasswd = resp.fields.curr_passwd;
     ans.newPasswd = resp.fields.new_passwd;
     ans.newPasswd2 = resp.fields.new_passwd2;
     ans.messages = resp.messages.splice(0);
     return Rx.Observable.of(ans);
 }
开发者ID:czcorpus,项目名称:kontext,代码行数:8,代码来源:profile.ts

示例8: to

  to(channelName: string, iO: Observable<any>): Subscription<any> {
    this.initChannel(channelName);

    return iO.subscribe(
      item => this.channels[channelName].forEach(fn => fn(item)),
      err => { throw err; },
      () => this.channels[channelName].forEach(fn => fn('__done'))
    );
  }
开发者ID:jonesnc,项目名称:gustav,代码行数:9,代码来源:GustavMem.ts

示例9:

subs.subscribe(({connection, message:{symbol}}:any) => {
  const source = Observable.interval(500).map(() => ({
    symbol,
    price: Math.random() * 100,
    timestamp: Date.now()
  }));
  connection.streams = connection.streams || {};
  connection.streams[symbol] = source.subscribe(connection);
});
开发者ID:LongLiveCHIEF,项目名称:aim,代码行数:9,代码来源:stock_server.ts

示例10: Error

 (data) => {
     console.log('data: ', data);
     if (data.lastpage && data.Items.length === 0) {
         throw new Error(this.layoutModel.translate('wordlist__page_not_found_err'));
     }
     this.data = this.importData(data.Items);
     this.isLastPage = !!data.lastpage;
     return Rx.Observable.of(data);
 }
开发者ID:czcorpus,项目名称:kontext,代码行数:9,代码来源:main.ts


注:本文中的@reactivex/rxjs.Observable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。