A Promise-like primitive which is lazy/cancelable, has typed errors, and emits synchronously instead of on the microtask queue. In a way LazyPromise is what you get if you take an Observable and make it impossible to misuse it for what the Signals were built to do.
Quick question - would something like this cover the basic cancelable promise use case, or am I missing something important about what LazyPromise does differently?
Yeah, I think this will cover the basic use-case, although the way I'd approach this is by starting with AbortSignal API and then maybe creating a wrapper around it. In a way `eager` and `lazy` functions from LazyPromise library are such wrappers.
About the two error channels: what I tried to do is to make it really easy to not use typed errors when you don't need them. In that case your promise is typed as `LazyPromise<Value, never>`.
Signals is a reactive primitive that has been initially introduced in SolidJS framework and have then made their way to other frameworks like Angular.
Author here. What's pretty cool about LazyPromise is that when it's paired with Signals, you can do some of the stuff that you'd otherwise do with functional reactive programming, but you don't have to tell your team to learn RxJS or another FRP library - instead there is an API that capitalizes on the existing knowledge of the native promise.
Interesting, interesting. It would take me a few hours of playing with this mechanism to know what I think of it as a primitive, but for me this solution is relevant to a problem I really have so I might take a look. Right now I just write methods that sometimes return a promise and sometimes don't.
guntis_dev|2 months ago
ivan7237d|2 months ago
nullzzz|2 months ago
The two separate failure channels turn me off. Is this practical or does it introduce unwanted complexity in most cases?
Also wondering what are the Signals that are mentioned.
ivan7237d|2 months ago
About the two error channels: what I tried to do is to make it really easy to not use typed errors when you don't need them. In that case your promise is typed as `LazyPromise<Value, never>`.
Signals is a reactive primitive that has been initially introduced in SolidJS framework and have then made their way to other frameworks like Angular.
lgas|2 months ago
ivan7237d|2 months ago
conartist6|2 months ago
ivan7237d|2 months ago
IntelliAvatar|2 months ago
MuffinFlavored|2 months ago
Kind of reminds me of https://doc.rust-lang.org/rust-by-example/trait/drop.html