• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript xstream.Stream类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1:

const complete = (some$: Stream<Marble>, time: number) => {
  some$.shamefullySendNext({
    time,
    complete: true
  });
  some$.shamefullySendComplete();
}
开发者ID:artfuldev,项目名称:xstream-marbles,代码行数:7,代码来源:helpers.ts


示例2: __commitBySha

 private __commitBySha(sha: string) {
   const response$$: Stream<Stream<Response>> = this.http.select(`commit-by-sha-${sha}`);
   return response$$
     .map(response$ => response$.replaceError(() => xs.of({ status: 500, body: {} } as Response)))
     .flatten()
     .map(response => response.body as Commit);
 }
开发者ID:cyclejs-community,项目名称:typescript-starter-cycle,代码行数:7,代码来源:github.ts


示例3: main

function main(sources: Sources): Sinks {
  const stateUpdate$ = sources.websocket.get('state-update')
    .map(msg => msg.data as BootstrapMessage)
  const board = isolate(Board)(sources, stateUpdate$)

  const boardWebsocket$ = Stream.merge(
    board.moveNote$.map(noteEvent => ({
      type: 'move-note',
      data: noteEvent,
    })),
    board.addNote$.mapTo({ type: 'add-note' }),
    board.editNote$.map(({ id, label }) => ({
      type: 'change-note-label',
      data: { id, label }
    })),
    board.noteDelete$.map(id => ({
      type: 'delete-note',
      data: { id }
    }))
  )

  return {
    DOM: board.DOM,
    websocket: Stream.merge(boardWebsocket$, Stream.of({ type: 'init' }))
      .debug('websocket$'),
    preventDefault: board.preventDefault,
    focus: board.focus,
  }
}
开发者ID:JamesHageman,项目名称:xstream-scrumbler,代码行数:29,代码来源:index.ts


示例4: intent

function intent(HTTPSource: HTTPSource): Intent {
  const url = 'http://swapi.co/api/people/'

  const usersReq$: Stream<RequestOptions> = xs.of({ url, category: 'users' })

  const users$: Stream<User[]> = HTTPSource
    .select('users')
    .flatten()
    .map((res: Response<UsersResBody>) => res.body.results)

  const homeworldsReq$: Stream<RequestOptions> = users$.map((users: User[]): Stream<RequestOptions> => {
    return xs.fromArray(users.map((user: User): RequestOptions => {
      return { url: user.homeworld, category: 'homeworld' }
    }))
  }).flatten()

  const homeworlds$ = HTTPSource
    .select('homeworld')
    .compose(flattenConcurrently)
    .map((res: Response<Planet>) => res.body)
    .fold((acc: Planet[], homeworld: Planet) => {
      acc = acc.concat(homeworld)
      return acc
    }, [])

  return { users$, homeworlds$, usersReq$, homeworldsReq$ }
}
开发者ID:jaketrent,项目名称:swapi-cycle-ts,代码行数:27,代码来源:index.ts


示例5: __commits

 private __commits() {
   const response$$: Stream<Stream<Response>> = this.http.select('commits');
   return response$$
     .map(response$ => response$.replaceError(() => xs.of({ status: 500, body: [] } as Response)))
     .flatten()
     .map(response => response.body as Commit[]);
 }
开发者ID:cyclejs-community,项目名称:typescript-starter-cycle,代码行数:7,代码来源:github.ts


示例6: operate

export const toMarbleStream = (marble$: Stream<Marble>, operate: (data$: Stream<string>) => Stream<string>): Stream<Marble> =>
  Stream.merge<Marble>(
    marble$
      .filter(({ complete }) => !complete)
      .map(({ data, time }) => operate(Stream.of(data)).map<Marble>(data => ({ time, data })))
      .flatten(),
    marble$
      .filter(({ complete }) => !!complete)
  );
开发者ID:artfuldev,项目名称:xstream-marbles,代码行数:9,代码来源:helpers.ts


示例7: constructor

 constructor(operator$: Stream<string>) {
   const xs = Stream;
   operator$.addListener(dummyListener);
   this.operator$ =
     operator$
       .map(operator => xs.of(operators[operator]))
       .flatten();
   this.operators$ =
     xs.of(keys(operators)).remember();
 }
开发者ID:artfuldev,项目名称:xstream-marbles,代码行数:10,代码来源:operators.ts


示例8: Button

function Button(sources: Sources): Sinks {
	let props$: Stream<ButtonProps> = sources.props$;
	const click$ = sources.DOM.select('.button').events('click')
	const delta$ = props$.map(
		(props) => click$.map((ev) => props.amount)
	).flatten();
	const vdom$ = props$.map(props => button('.button', [props.text]));

	return {
		DOM: vdom$,
		delta$: delta$
	}
}
开发者ID:mxstbr,项目名称:cyclejs-counter,代码行数:13,代码来源:Button.ts


示例9: start

      return function delayByOperator<T>(stream: Stream<T>): Stream<T> {
        return xs.create<T>({
          start(listener) {
            const {schedule, currentTime} = timeSource.createOperator();

            stream.addListener({
              next(t: T) {
                const delay = delaySelector(t);

                schedule.next(listener, currentTime() + delay, t);
              },

              error(err: Error) {
                schedule.error(listener, currentTime(), err);
              },

              complete() {
                schedule.complete(listener, currentTime());
              },
            });
          },

          stop() {},
        });
      };
开发者ID:ntilwalli,项目名称:cyclejs,代码行数:25,代码来源:time.ts


示例10: totalIsolateSink

export function totalIsolateSink(
  sink: Stream<VNode | null | undefined>,
  fullScope: string,
): Stream<VNode | null | undefined> {
  return sink.map(node => {
    if (!node) {
      return node;
    }
    // Ignore if already had up-to-date full scope in vnode.data.isolate
    if (node.data && (node.data as any).isolate) {
      const isolateData = (node.data as any).isolate as string;
      const prevFullScopeNum = isolateData.replace(/(cycle|\-)/g, '');
      const fullScopeNum = fullScope.replace(/(cycle|\-)/g, '');

      if (
        isNaN(parseInt(prevFullScopeNum)) ||
        isNaN(parseInt(fullScopeNum)) ||
        prevFullScopeNum > fullScopeNum
      ) {
        // > is lexicographic string comparison
        return node;
      }
    }

    // Insert up-to-date full scope in vnode.data.isolate, and also a key if needed
    node.data = node.data || {};
    (node.data as any).isolate = fullScope;
    if (typeof node.key === 'undefined') {
      node.key = SCOPE_PREFIX + fullScope;
    }
    return node;
  });
}
开发者ID:joeldentici,项目名称:cyclejs,代码行数:33,代码来源:isolate.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript concat.default函数代码示例发布时间:2022-05-25
下一篇:
TypeScript xstream.Listener类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap