- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在学习 CycleJS,我发现在使用 Cycle 的 HTTP 驱动程序时,我必须使用 RxJS switch/mergeAll
合并 response stream 流
以达到流级别.但是当我尝试应用这些函数时,出现类型错误:switch is not a function
(在响应流流上)。
const response$$ = sources.HTTP
.filter(response$ => response$.request.url === 'http://jsonplaceholder.typicode.com/users/1')
const response$ = response$$.switch()
如果我遗漏了什么,你能告诉我吗?
最佳答案
@cycle/http filter
返回一个 metastream,因此它没有 stream 的功能。
要获取流,在您过滤
之后,从生成的metastream 中提取response$$
流使用response$$
,然后flatten
它:
const response$$ = sources.HTTP
.filter(response$ => response$.request.url === 'http://jsonplaceholder.typicode.com/users/1')
.response$$
const response$ = response$$.flatten()
现在您可以继续使用 map
等。(可用的运算符取决于您使用的 Cycle.js 的版本。最新的使用 xstream 作为流 引擎。)
@cycle/http response$$
With an HTTP Source, you can also use
httpSource.response$$
to get the metastream. You should flatten the metastream before consuming it, then the resulting response stream will emit the response object received through superagent.
或者你可以简单地:
const response$ = sources.HTTP
.filter(response$ => response$.request.url === 'http://jsonplaceholder.typicode.com/users/1')
.response$$.flatten()
现在您可以按预期使用 response$
了。
关于javascript - switch/mergeAll/flatten 不是函数 - 在 cyclejs 中使用 http 驱动程序时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38166395/
我正在尝试学习 cyclejs 和响应式编程,但我不知道如何使用值来管理事件。 例如,我需要创建四个函数来进行一些数学运算,例如: 补充 减法 师 乘法 这是我的代码: function main (
我想开始我的第一个 Cycle.js 项目,我将与 friend 一起开发它。他是一名 HTML 设计师(对 HTML 和 CSS 非常了解,并且他创建了 Handlebars 模板),我对 JS 略
我尝试使用Cyclejs/xstream创建一个简单的待办事项应用程序。该应用程序运行良好。我唯一无法理解的是添加每个待办事项后输入应该清除,但这没有发生。 todo.js import {
我尝试通过 SystemJS 从他们的 CDN 加载 Cycle DOM,例如: System.config({ map: { 'cycle-dom': 'https://unpkg.co
我正在尝试从记录其 map 运算符内部的数组创建流,但我的代码似乎出了点问题,我无法指出... import {Slider} from './slider/slider' import xs fro
假设我有一个返回用户详细信息的 API:/api/get_user/1 { "status": 200, "data": { "username": "username1",
我必须将 token 保存在浏览器的 cookie 中(在我的例子中是 Chrome)。我发现https://github.com/10clouds/cyclejs-cookie该资源并安装了0.5.
我一直在尝试创建一些cycle.js 示例作为嵌套对话,并使用选择框在它们之间进行切换。 其中一个对话是官方 Github HTTP 搜索示例的克隆。 另一个对话是一个更基本的对话,没有 HTTP,只
给定一个用 CycleJs 构建的独立组件(该组件工作正常): import isolate from '@cycle/isolate'; import { div, ul, li, a } from
我正在尝试使用 CycleJS HTTP 驱动程序向 REST 端点发出请求,但我获取输入字段值的方式不是响应式的,但我无法找到一种方法来做它(正确的方式) 用户案例: 用户填写用户名和密码字段,然后
我已经编写了一个 Spring Controller ,它在请求中接收 json 并响应 pdf 文件。 public ResponseEntity generateResp(...) by
我正在努力研究 CycleJS,但我被卡住了!我正在尝试将一个小应用程序放在一起加载一个包含对象数组的 JSON 文件,但我无法让该应用程序执行 http 请求 到目前为止在我的代码中 'use st
我正在使用 cycleJS 制作一个表情符号查看器应用程序,用户可以在其中单击任何表情符号以将其添加/从他们的收藏夹列表中删除。每次更改时,该列表也会保存到 localstorage。我正在使用 fo
Bower:我找不到 @Cycle/Core、@Cycle/DOM 的 Bower 包,这些库是否存在?我很困惑为什么首先会有一个 NPM 包,因为 Cycle.js 是基于前端的(而 NPM 专门用
我正在研究 cyclejs,但在处理如何使 div 移动时遇到了一些麻烦。 首先,我隔离了 3 个我必须计算的事件 鼠标按下 鼠标弹起 鼠标移动 目的是在 map 按下和鼠标移动时产生移动,并在我鼠标
使用 vanilla JavaScript,我将执行以下操作以将 h1 标记添加到 iframe 主体: var doc = document.getElementById('iframe').con
我正在玩cyclejs,我试图找出处理许多源/意图的惯用方法应该是什么。我在下面有一个简单的 Cyclejs 程序,用 TypeScript 编写,并对最相关的部分进行了注释。 您是否应该像在 Elm
我想知道 Cycle.js、motorcycle.js、most.js 和 snabbdom 是否有 tsd 定义。 最佳答案 不,还没有。但它们将在即将发布的版本中出现(我们目前正在努力)。 关于c
我正在尝试获取一个包含 10 个对象的随机 Observable 流,每个对象都具有如下属性: {tileNum: '6', tileName: 'game-of-thrones' clickCoun
我正在学习 CycleJS,我发现在使用 Cycle 的 HTTP 驱动程序时,我必须使用 RxJS switch/mergeAll 合并 response stream 流 以达到流级别.但是当我尝
我是一名优秀的程序员,十分优秀!