Front-end
Apple
Apple
  • 第三方库
    • RAC库
      • ReactiveObjc
        • 如何实现的
        • 有关类
        • 有关协议
        • 关键概念列表
          • RACSignal有关类
            • RACStream
              • 头文件定义
            • RACSignal
              • 头文件定义内容
              • 核心代码
              • 常用的方法
                • concat:
                • bind:
                • zipWith 和merge
            • RACSubject
              • 内容
            • RACReplaySubject
              • 内容
            • RACBehaviorSubject
              • 内容
            • RACGroupedSignal
              • 内容
            • RACDynamicSignal
              • RACDynamicSignal
              • RACSignal vs RACDynamicSignal
            • RACReturnSignal
              • 内容
            • RACErrorSignal
            • RACEmptySignal
            • RACChannelTerminal
            • 疑问
              • RACChannelTerminal vs RACSubject
              • RACSignal vs RACStream
              • 热信号和冷信号
                • 进一步理解
              • 信号的发送者和接受者
                • RACSignal 不是信号对象么?为什么信号的发送者是自己呢?
          • RACChannel有关类
            • RACChannel
              • Page 1
              • 用于MVVM架构
              • RAC() vs RACChannelTo()
            • RACKVOChannel
              • 内容
              • 封装了系统的KVO
          • RACCommand
          • RACSubscriber
          • RACTuple
          • RACSequence有关类
          • RACKVOTrampoline
            • NSObject+RACKVOWrapper.h
            • NSObject+RACKVOWrapper.m
          • Page
          • 宏
          • 疑问
            • RACCommand vs RACSignal
            • 有了信号量,为什么还需要RACCommand
        • 操作方法
          • reduce
            • reduce 在不同语言以及库中是否一样的概念?
      • ReactiveSwift
        • 相比ReactiveObjc
      • RxSwift
      • Combine
      • 疑问
        • 热信号 vs 冷信号
        • ReactiveObjC 和 ReactiveSwift 实现原理差异
        • ReactiveObjC、ReactiveCocoa、ReactiveSwift的关系与区别
        • ReactiveObjC、ReactiveCocoa、ReactiveSwift内容
        • ReactiveSwift vs RxSwift
        • RxSwift、ReactiveSwift 和 ReactiveObjC
        • RxSwift、ReactiveSwift 、Combine
    • swift源码
      • 编译
        • 命令参数解释
        • 涉及到的工具
          • cmake 和 ninja
          • sccache
        • Rosetta模式
        • 遇到问题
          • FETCH_HEAD': Permission denied
          • --local_compiler_build': No such file or directory
          • ld: unsupported tapi file type '!tapi-tbd' in YAML file
          • python --version 显示没有这个命令
          • ModuleNotFoundError: No module named 'packaging'
          • ModuleNotFoundError: No module named 'sphinx'
            • sphinx是什么
          • ERROR: Could not find a version that satisfies the requirement sphinx (from versions: none)
          • /Applications/Python\ 3.x/Install\ Certificates.command 失败
          • 已经安装了sphinx,还是显示错误
      • 涉及到的知识点
        • Swift中的MCCAS
Powered by GitBook
On this page
  1. 第三方库
  2. RAC库
  3. 疑问

RxSwift、ReactiveSwift 、Combine

下面是 RxSwift、ReactiveSwift 和 Combine 的关系与区别,以表格的形式列出:

特性
RxSwift
ReactiveSwift
Combine

起源

基于 Rx 标准 (Reactive Extensions)

基于 ReactiveCocoa,原生 Swift 实现

Apple 官方框架,iOS 13 及以上版本引入

支持语言

Swift

Swift

Swift

核心类型

Observable

Signal 和 SignalProducer

Publisher 和 Subscriber

线程调度

使用 Schedulers 控制线程

使用 Scheduler 控制线程

内置 DispatchQueue 和 RunLoop

异步流

Observable 管理事件流

Signal 用于即时事件,SignalProducer 用于惰性计算

Publisher 生成异步流,Subscriber 处理

操作符支持

丰富的 Rx 标准操作符

Swift 风格的操作符

基于 Swift 的内置操作符

平台支持

iOS、macOS、跨平台 Rx 家族成员

iOS、macOS

iOS、macOS、watchOS、tvOS

典型应用

跨平台响应式编程、具有 Rx 风格的 API

纯 Swift 项目,与 Swift 类型系统紧密结合

使用 Apple 框架的项目

资源和社区

Rx 社区支持广泛、资源丰富

Swift 社区支持,资源相对较少

Apple 官方支持,资源多且持续更新

常见扩展

RxCocoa 提供 UIKit 和 Foundation 支持

与 Swift 原生库兼容

与 SwiftUI、UIKit 和 Foundation 深度整合

适用场景

需要跨平台一致性、Rx 标准一致性

偏向 Swift 开发,支持更高级别的流控制

依赖 Apple 框架的项目及新特性

总结:

  • RxSwift:适合跨平台 Rx 系统,具有 Rx 风格的 API 和丰富的操作符。

  • ReactiveSwift:适合 Swift 项目,与 Swift 语言深度集成,但社区资源少。

  • Combine:Apple 官方框架,推荐在 iOS 13 及以上项目中使用,拥有更好的一体化支持与性能。

PreviousRxSwift、ReactiveSwift 和 ReactiveObjCNextswift源码

Last updated 8 months ago