-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Now that WWDC has come and gone, I'd be curious to hear general thoughts on the future of PromiseKit. (Especially @mxcl's, of course.)
Unless I missed something, there weren't any significant changes to Combine this year, so I guess Apple considers it complete. It's not really a potential moving target anymore.
I do not think Combine replaces PromiseKit. I like Combine more than RxSwift (the only other streaming system I've actually used), but despite the general similarities, PromiseKit is still a much nicer API for the use cases it targets. I hope and plan to continue using it (or something like it) in the future.
However, PromiseKit is living in Combine's world now, so it seems like it needs a Combine-aware overhaul to exploit conceptual similarities. And I suspect that a large part of the PromiseKit API could be reimplemented as a layer over Combine, slimming both the codebase and the maintenance burden. Is this reasonable or is it crazy talk?
Things that seem at first glance like they ought to be shared with Combine:
- General terminology
- Dispatching/scheduling system
- Cancellation system
- Platform-supported APIs that vend promises/publishers
- Multiple downstream links require explicit .shared()
Things that seem like they should continue to work differently for promises:
- Only one error or one result (duh)
- Promises are self-retaining and self-freeing; no need for retainer objects
- Errors are always thrown; no separate error transmission or receiving API
- No operators that disallow throwing
- No client protocols to implement - chain structure determines behavior
- No subscriptions
- No backpressure/connectability/demand management
ensure
andfinally
- Resolver API (aka "seal" or what Combine calls a Promise)
- Errorless chains are a separate type (Guarantee)
- Promises retain their result until deallocated
Some of this is potentially painful. E.g., then
makes a heck of a lot more sense than flatMap
for what it does, especially in the context of promises.
Most of the v7 work I've done on PromiseKit seems irrelevant to a post-Combine world. I'm not sure to what extent that extends to other aspects of v7. In any case, I don't have any problem ditching all that in favor of something more responsive to the current situation.