本文整理汇总了TypeScript中xstream.Stream.of方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Stream.of方法的具体用法?TypeScript Stream.of怎么用?TypeScript Stream.of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xstream.Stream
的用法示例。
在下文中一共展示了Stream.of方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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,
}
}
示例2: StreamView
export const ReadonlyStreamView = ({ marbles$ }: ReadonlySources): Sinks =>
StreamView({
marbles$,
readonly$: Stream.of(true),
dom: undefined
});
示例3: operate
.map(({ data, time }) => operate(Stream.of(data)).map<Marble>(data => ({ time, data })))