hx-2.4g-rx-2

by Ahmed Rizwan

通过艾哈迈德·里兹万(Ahmed Rizwan)

Rx-如果话务员可以讲话! (Rx — If the Operators could speak!)

If the operators could talk, how exactly would they tell us what they do?

如果操作员可以交谈,他们将如何确切地告诉我们他们在做什么?

In order to take full advantage of Rx, you need a clear understanding of what Rx Operators are and what they do.

为了充分利用Rx,您需要清楚了解Rx运算符是什么以及它们的作用。

This is what the Operators would be telling the observables if they could talk when we use them.

这就是操作员会告诉可观察对象在我们使用它们时可以说话的意思。

For this article, I’ll assume that you already know what Rx is. If not, go read this. Or just simply google Rx and you’ll find a ton of helpful articles, tutorials, and videos.

对于本文,我假设您已经知道Rx是什么。 如果没有,请阅读此内容 。 或者只是简单地使用google Rx,您会发现大量有用的文章,教程和视频。

创新运营商 (Creational Operators)

创造 (Create)

I tell you what to emit, when to terminate, and what error to throw. ‘Cause I’m the boss.

我告诉您发出什么,何时终止以及抛出什么错误。 因为我是老板。

延期 (Defer)

You only get to “create” yourself once someone subscribes to you. And it’ll be a brand new version of yourself every single time.

一旦有人订阅了您,您就只能“创建”自己。 每次都将是您自己的一个全新版本。

空的 (Empty)

Hm. Emit nothing. And then die, please.

嗯 什么都不散。 然后死。

决不 (Never)

Emit nothing. And don’t… ever… terminate.

什么都不散。 而且不要……永远……终止。

扔 (Throw)

Emit nothing, and then throw an error, OK?

什么都不发,然后抛出错误,好吗?

从 (From)

I’ll give you some objects, then you emit them right back at me.

我给你一些东西,然后你把它们放回我身边。

间隔 (Interval)

How about this: you emit items. But not immediately. Send them back, one by one, after certain “intervals.”

怎么样:您发射物品。 但不是立即。 在某些“间隔”之后,将它们一一寄回。

只是 (Just)

I need just one thing back from you. Just one.

我只需要你退回一件事。 只有一个。

范围 (Range)

I give you a range of integers, then you emit back all the values in that range.

我给您一个整数范围,然后您发出该范围内的所有值。

重复 (Repeat)

How about you emit that same object repeatedly.

您如何反复发射相同的对象。

开始 (Start)

Ok. I have a function. When it returns, you start emitting. But only when it returns. Got it?

好。 我有一个功能。 当它返回时,您开始发射。 但是只有当它返回时。 得到它了?

计时器 (Timer)

So you got an item. Don’t emit it just yet. I’ll tell you the exact time when you should emit it. Don’t jump the gun.

所以你有一个项目。 暂时不要发射。 我会告诉您确切的发射时间。 不要跳枪。

转化算子 (Transformational Operators)

缓冲 (Buffer)

Ok, so here’s the deal. Whatever it is you normally emit, well don’t emit that. Instead ,collect the items into bundles over time. And send bundles instead. ‘Cause I want bundles!

好的,这是交易。 无论您通常发出什么信号,都不要发出。 取而代之的是,随着时间的流逝,将物品收集成捆。 并发送捆绑包。 因为我要捆绑!

平面图 (FlatMap)

So, like, if you have lists of items and there’s another observable that’s full of items, can you please “flatten” yourself and that observable so you can just send items?

因此,例如,如果您有项目列表,而又有一个可观察项目充满了项目,您能否请自己“扁平化”该可观察项目,以便仅发送项目?

地图 (Map)

Transform each item into another item.

将每个项目转换为另一个项目。

扫瞄 (Scan)

Transform each item into another item, like you did with map. But also include the “previous” item when you get around to doing a transform.

将每个项目转换为另一个项目,就像处理地图一样。 但是,当您要进行转换时,还应包括“上一个”项目。

筛选运算符 (Filtering Operators)

去抖动 (Debounce)

Only emit if a certain amount of time is passed.

仅在经过一定时间后才发射。

不同 (Distinct)

Emit only distinct items. All right?

仅发射不同的项目。 行?

ElementAt (ElementAt)

I tell you the index. You emit the item at that index.

我告诉你指数。 您在该索引处发射项目。

过滤 (Filter)

I give you a criteria. You give me items that pass the criteria.

我给你一个标准。 您给我符合条件的物品。

第一 (First)

Just give me back the first item.

请把第一项还给我。

忽略元素 (IgnoreElements)

Do not, I repeat, do not emit a single item. And then die.

我再说一遍,不要发出单个物品。 然后死。

持续 (Last)

Just give me back the last item.

请把最后一件还给我。

样品 (Sample)

I give you an interval. You give me only the most recent items from that that interval.

我给你一个间隔。 您只给我该间隔内的最新物品。

跳跃 (Skip)

OK, skip the first n items, would you?

好,跳过前n个项目,对吗?

跳过最后 (SkipLast)

Skip the last n item s. Yeah, those ones.

跳过最后n个项目。 是的,那些。

采取 (Take)

Emit only the first n items.

仅发射前n个项目。

最后一次 (TakeLast)

Emit only the last n items.

仅发射最后n个项目。

合并运算符 (Combining Operators)

合并 (Merge)

Here are two observables. Let’s pretend they’re only one observable.

这是两个观察值。 假设它们只是一个可观察的对象。

从...开始 (StartWith)

Here are two observables. But I get to tell you which one to start with.

这是两个观察值。 但是我要告诉你从哪一个开始。

合并最新 (CombineLatest)

Here are two observables. Between the two, make pairs of the latest items.

这是两个观察值。 在这两者之间,制作成对的最新商品。

压缩 (Zip)

Here are two observables. But I tell you how to combine their items (through a function, of course).

这是两个观察值。 但是,我告诉您如何组合它们的项目(当然是通过函数)。

处理错误 (Handling Errors)

抓住 (Catch)

After an error is thrown, continue on with the emits.

引发错误后,继续进行发射。

重试 (Retry)

After an error is thrown, restart from the very beginning.

引发错误后,请从头开始重新启动。

效用 (Utility)

延迟 (Delay)

Just add a delay before you start emitting, OK?

只是在开始发射之前增加一个延迟,好吗?

观察 (ObserveOn)

“Observational” code should run on this particular thread.

“观察性”代码应在此特定线程上运行。

SubscribeOn (SubscribeOn)

“Subscription” code should run on this particular thread.

“订阅”代码应在此特定线程上运行。

订阅 (Subscribe)

You can start emitting now. *music intensifies*

您可以立即开始发射。 *音乐增强*

时间间隔 (TimeInterval)

OK, so observables send back items, right? Instead, I want you to send the time intervals back. Like the time differences between each emission.

好了,可观察物会发回物品,对吧? 相反,我希望您将时间间隔发送回去。 就像每次发射之间的时间差一样。

超时 (TimeOut)

Set a TimeOut on each emission. And if an item doesn’t get emitted within that time, just throw an error ?

为每个发射设置一个超时。 如果在此时间内没有发出任何物品,则抛出错误

条件和布尔 (Conditional and Boolean)

所有 (All)

If all items fulfill a certain criteria, return true.

如果所有项目均满足特定条件,则返回true。

安布 (Amb)

Here are at least two observables. Give me the one that starts emitting first.

这里至少有两个可观察到的东西。 给我一个开始发光的东西。

包含 (Contains)

If I ask for an item, can you tell me whether you already have it?

如果我要一个东西,你能告诉我是否已经有了吗?

DefaultIfEmpty (DefaultIfEmpty)

When you have nothing to emit, here’s a default value that you can send back.

当您什么都没有发出时,这是您可以发送回的默认值。

序列相等 (SequenceEqual)

Here are two observables. Return true if their items (and their sequence) are the same.

这是两个观察值。 如果它们的项目(及其顺序)相同,则返回true。

跳过直到 (SkipUntil)

Here are two observables. Skip the items of the first one until the second one starts emitting.

这是两个观察值。 跳过第一个项目,直到第二个项目开始发射。

跳过而 (SkipWhile)

I give you a condition. You emit items until that condition becomes false.

我给你一个条件。 您发出物品,直到该条件变为假。

直到 (TakeUntil)

Here are two observables. Only give me the items of the first one until the second one starts emitting.

这是两个观察值。 请只给我第一个的物品,直到第二个开始散发出来。

数学运算符 (Mathematical Operators)

平均 (Average)

Give me an average of your Integer items.

给我您的整数项目的平均值。

计数 (Count)

Give me a count of your items.

给我数你的物品。

最高 (Max)

Emit only the maximum-valued item.

仅发射最大价值的物品。

敏 (Min)

Emit only the minimum-valued item.

仅发射最小值的项目。

减少 (Reduce)

Do a scan, but only emit the final value.

进行扫描,但仅发出最终值。

和 (Sum)

Return the sum of all your items.

返回所有项目的总和。

转换运算符 (Conversion Operators)

至 (To)

Convert an observable into a List, Map or Array, or whatever I tell you to.

将可观察对象转换为列表,映射或数组,或任何我告诉您的对象。

That’s it for now. There are other operators as well, which you can find here. You can also check out RxMarbles, which has cool diagrams for demonstrating each operator.

现在就这样。 还有其他运算符,您可以在这里找到。 您也可以签出RxMarbles ,其中具有用于演示每个运算符的漂亮图表。

Anyway, thank you for reading. I hope the article helped you better understand what each of these commands does in a fun way.

无论如何,谢谢您的阅读。 我希望本文能帮助您更好地了解这些命令的有趣方式。

Happy coding!

编码愉快!

翻译自: https://www.freecodecamp.org/news/rx-if-the-operators-could-speak-58567c4618f1/

hx-2.4g-rx-2

hx-2.4g-rx-2_Rx-如果话务员可以讲话!相关推荐

  1. 使用raphael.js绘制带全省标识的中国地图_1

    https://www.helloweba.net/javascript/242.html 此链接为最初的源码网站.经过修改的在我这里. raphael.js // ┌──────────────── ...

  2. 4g 控矿驱动 迪兰rx574_迪兰RX 570 4G X-Serial显卡驱动官方正式版下载,适用于win8,win7,win10-驱动精灵...

    驱动说明: 图形芯片Radeon RX570 流处理器数量2048 显存容量4GB GDDR5 核心频率1244/1270MHz 显存频率7000MHz 显存位宽256-bit DirectX12 总 ...

  3. 移动通信网络频段大全,含5G、4G,各种公开频段汇总

    转载自<http://www.openpcba.com/web/contents/get?id=3097&tid=15> 首先看看无线电信号的频谱如何划分: 01 5G NR 3G ...

  4. 如何为编程爱好者设计一款好玩的智能硬件(十)——无线2.4G通信模块研究·一篇说完...

    六.温湿度传感器DHT11驱动封装(下):如何为编程爱好者设计一款好玩的智能硬件(六)--初尝试·把温湿度给收集了(下)! 七.点阵字符型液晶显示模块LCD1602驱动封装(上):如何为编程爱好者设计 ...

  5. 4G模块使用记录移远EC20、BC20

    目录 0. 概述 硬件连接 -- UART 休眠管脚的使用 硬件连接 -- USB USB线序定义 驱动安装 抓取模组log 模组型号和SIM卡 模组区别 本地卡和漫游卡 SIM卡和APN 1. EC ...

  6. CAT1模块EC200S 4G物联网模块串口透传MQTT协议 快速入门指导资料

    EC200S是广州斯迈尔特推出的一款工业级,小体积自带STM32CPU,引出串口.SPI\AD等常用接口,用户只要通电就能应用到自己的产品中.EC200S的版本已经完全可以支持UDP TCP PPP ...

  7. phython在file同时写入两个_RTX 3080出生两个月卒!Radeon RX 6800/6800 XT首发评测

    原标题:RTX 3080出生两个月卒!Radeon RX 6800/6800 XT首发评测 一.前言:出乎所有人预料的RDNA2构架 2020年9月4日,当NVIDIA基于新一代Ampere安培架构的 ...

  8. 2.4G无线音频双向传输技术运用

    2.4G无线音频双向传输技术运用 1.产品描述 A8810S1 是一对远距离的 2.4G 无线音频传输模组.模组专业的 RF 电路设计配合独有的软件跳频机制,有效提高了 RF 的抗干扰能力及传输距离. ...

  9. 4G模块SIM7600绑定AT指定串口号(二)

    0.问题描述 4G模块SIM7600插上USB线后会有5个串口号,在电脑没有其他串口插入情况下AT指令串口为/ttyUSB2,但是在机器人上使用时会有其他多个串口,一般我们会绑定串口建立符号链接,例如 ...

最新文章

  1. 使用python包faker生成仿真数据
  2. mysql 浏览器插件_Chrome浏览器BlazeMeter插件安装图解
  3. 两种控制器的跳转与回跳
  4. 该项研究降低了使用大脑信号控制机器人手臂的位置误差
  5. ES 自动恢复分片的时候不恢复了是磁盘超过了85%,然后不恢复了 ES可以配置多个数据目录...
  6. 《JavaScript入门经典(第6版)》——2.7 问答
  7. python progressbar 多行_使用单击.progressbar在Python中使用多处理
  8. 详解Python的*args和 **kwargs
  9. JS 中判断一个对象是否为数组对象?
  10. 《Python Cookbook 3rd》笔记(4.3):使用生成器创建新的迭代模式
  11. WCF学习笔记(三):开启net.tcp端口
  12. Unity cg vertex and fragment shaders(二)
  13. android 添加新用户,华为手机怎么添加新用户?华为手机添加新用户的方法
  14. 探测内网c段、外网某网站(ip)的网络服务存活状态
  15. IoC容器4——依赖
  16. 剧本创作时的标准格式,让你的剧本轻松得到制片公司青睐
  17. Linux——MySQL分表分区
  18. 电容0.1uF和104有什么区别?
  19. Sqlserver 中的Iif语句
  20. R语言sem包实现通径分析

热门文章

  1. 虚拟机非正常关闭,里面的服务器重启报错:Error, some other host already uses address...
  2. Qt中鼠标滑过控件由箭头变成手型QWidget::setCusor()
  3. Bilibili到底有多少御坂妹?(三)
  4. 【华为云服务之】在华为云ECS上安装Docker
  5. html名人名言页面,网页制作:关于生命的名言警句 ― 名人名言  一品故事网,Www.07938.Come...
  6. 13-MyBatis 使用了哪些设计模式?在源码中是如何体现的?
  7. 小学生python游戏编程2----飞机大战1
  8. US zip code
  9. 四步教你用网站源码建站
  10. turtle绘制五角星