Hey everyone, I built reaktiv, a small reactive signals library for Python, inspired by Angular’s reactivity model. It lets you define Signals, Computed Values, and Effects that automatically track dependencies and update efficiently. The main focus is async-first reactivity without external dependencies.<p>Here is an example code:<p>```
import asyncio
from reaktiv import Signal, ComputeSignal, Effect<p>async def main():
count = Signal(0)
doubled = ComputeSignal(lambda: count.get() * 2)<p><pre><code> async def log_count():
print(f"Count: {count.get()}, Doubled: {doubled.get()}")
Effect(log_count).schedule()
count.set(5) # Triggers: "Count: 5, Doubled: 10"
await asyncio.sleep(0) # Allow effects to process
</code></pre>
asyncio.run(main())
```
For those of use that haven't use Angular, can you explain what this is doing? And what's it do that we can't already do with asyncio? Also, it's weird you have to call `asyncio.sleep(0)`. Seems like you should be able to `await count.set(5)`.<p>I did look at the repo, but I couldn't easily understand the use case and what exactly it's doing from examples alone.
What kinds of Python programs would benefit from Signals? Most of the Python I've written is either small CLI tools that run to completion, or boring web servers using frameworks like Django that are request-response oriented, which also has a "run-to-completion" model for a request's handler code.<p>Also, I looked at your implementation, and your ComputedSignal implementation is not sound - it can give inconsistent results with respect to the input signals depending on the ordering of reads when you have a ComputedSignal that depends on other ComputedSignal.
Cool (probably), but it's not clear what it does or how useful it is when one doesn't know anything about Angular signals. Could you explain?<p>Also, care to compare to RxPY? (<a href="https://github.com/ReactiveX/RxPY">https://github.com/ReactiveX/RxPY</a>)
HN doesn't support markdown unfortunately. As such your code block's formatting is all messed up there.<p>Not your fault of course. Just thought you'd wanna know.<p>P.S. - HN staff please add markdown support. I'm sure this gets mentioned 10 times a day, so this is mention 11.