简体   繁体   English

ReactiveCocoa和PromiseKit之间的主要区别是什么?

[英]What's the main difference between ReactiveCocoa and PromiseKit?

ReactiveCocoa use RACSignal and PromiseKit use Promise to wrap values. ReactiveCocoa使用RACSignal和PromiseKit使用Promise来包装值。 They can both chain asynchronous works together. 它们都可以将异步工作链接在一起。 What's the main design difference between ReactiveCocoa and PromiseKit? ReactiveCocoa和PromiseKit之间的主要设计区别是什么?

signals and promises are both ways to represent asynchronous operations as typed values that can be passed around, chained, composed, nested, etc in ways that a callback/notification/delegate cannot. signal和promise都是将异步操作表示为类型化的值的两种方法,这些类型的可以以回调/通知/代理无法传递的方式传递,链接,组合,嵌套等。

the difference between the two is like the difference between a square and a rectangle, where all promises are signals but not all signals are promises. 两者之间的差异就像正方形和矩形之间的差异一样,其中所有的承诺都是信号,但并非所有的信号都是承诺。 a promise is one specific use case of a signal. 承诺是信号的一种特定用例。

a signal represents a timeline of any number of asynchronous events, terminated by a completion or a failure. 信号表示由完成或失败终止的任何数量的异步事件的时间轴。 The following diagrams are all possible signals- any number of events ending in a failure or completion 下图是所有可能的信号-任何数量的事件以失败或完成而结束

--------------------Event(eventData)-Completion()

--------------Completion()

Event(eventData)---------Event(eventData)----------Failure(errorData)

-------------------------------------Failure(errorData)

a promise represents a single asynchronous event or a single asynchronous failure. 一个promise表示单个异步事件或单个异步故障。 the following diagrams represent possible promises: 下图表示可能的承诺:

-------Completion(eventData)

----------------------------------------------Completion(eventData)

--------Failure(errorData)

------------------------Failure(errorData)

as you can probably already see, any promise can be represented by a signal that sends Completion immediately after it sends its first Event, like so: 如您可能已经看到的,任何promise都可以由在发送第一个Event之后立即发送Completion的信号来表示,如下所示:

-------Event(data)+Completion()

-------------------------------------------Event(data)+Completion()

--------Failure(errorData)

------------------------Failure(errorData)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 textField委托与在ReactiveCocoa中使用textSignal有什么区别? - What's the difference between textField delegate and using textSignal in ReactiveCocoa? GCD 中的“全局队列”和“主队列”有什么区别? - What's the difference between the “global queue” and the “main queue” in GCD? 主队列上的 performSelectorOnMainThread: 和 dispatch_async() 有什么区别? - What's the difference between performSelectorOnMainThread: and dispatch_async() on main queue? 属性观察者和属性包装器之间的主要区别是什么? - What's the main difference between property observers and property wrappers? 在iOS应用中,主捆绑包和文档目录有什么区别? - In iOS apps , what's the difference between the main bundle and the documents directory? 主事件循环和应用程序的运行循环有什么区别? - What's the difference between main event loop and app's run loop? “auto”和“instancetype”类型的主要区别是什么? - What is main difference between “auto” and “instancetype” type? 这两个main.m有什么区别? - What is the difference between these two main.m? swift中的:和=有什么区别 - What's the difference between : and = in swift 然后在Promisekit中重新加载tableview - Reloading tableview in Promisekit's then
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM