|
|
|
|
|
by philote
512 days ago
|
|
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)`. I did look at the repo, but I couldn't easily understand the use case and what exactly it's doing from examples alone. |
|
In frontend frameworks, Signals eliminate the need for manual subscriptions and event handling, making state updates more efficient. I wanted the same benefits for backend systems where changes to shared state should propagate automatically, without polling, callbacks, or race conditions.
For example, if a config value or cached result updates, anything depending on it should react immediately. With Signals, you don’t have to manually notify consumers or keep track of what depends on what. It just works (hopefully).
About `asyncio.sleep(0)`: it’s just there to keep the example concise. Normally, you’d be inside an async function that naturally yields control, like handling a request or waiting for I/O.