ProtoPromise best practices? #189
-
Hi! Love ProtoPromise so far, thank you! Long time veteran but only doing C# and Unity a couple years and currently wrapping my head around async/await. I'm trying get best practices in how ProtoPromise should play with Suppose you're is building an awaitable suite from scratch using ProtoPromise -- where principle calls tend to be awaitable "all the way down" until they reach things like web requests, file loads, and embedded library calls. I would love to simplify and replace everything wholesale ProtoPromise but I find the whole Thanks ~ Drew |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 18 replies
-
Hi Drew, ProtoPromise should be able to completely replace For any existing APIs that need to work with
Basically, that behaves the same as
It's safe to assume Does that help? |
Beta Was this translation helpful? Give feedback.
Hi Drew,
ProtoPromise should be able to completely replace
Task
andValueTask
for all async methods that you write.For any existing APIs that need to work with
Task
orValueTask
that you do not control, you can convert to/from ProtoPromise by using thetask.ToPromise()
extensions, orpromise.ToTask()
/promise.AsValueTask()
extensions, as mentioned in the readme https://github.com/timcassell/ProtoPromise#task-interoperability.Basically, that behaves the same as
Task<T>
, but is more efficient if the method completed immediately. ProtoPromise has that same optimization built-in.