Hacker News

Show HN: LazyPromise = Observable – Signals

23 points by ivan7237d ago | 4 comments
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.

nullzzz |next [-]

Interesting stuff!

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.

conartist6 |next |previous [-]

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.

lgas |next |previous [-]

Do you want monads? Because this is how you get monads.

MuffinFlavored |previous [-]

> except you can optionally return a teardown function, for example:

Kind of reminds me of https://doc.rust-lang.org/rust-by-example/trait/drop.html