Open progval opened 3 years ago
Another random idea, but unrelated to labeled-response, but related to the latter: it could be useful to have async procedures like this to wait for an action; eg. when implementing turn-based games waiting for players to run a command.
To fully benefit from labeled-response, we should provide an easy way for plugins to send a message and run code on a reply without manually managing state.
Current pseudo-code:
That's a lot of boilerplate, so I'd like to provide a simple API like this to plugins:
Or maybe even introduce async command functions:
The later is the most developer-friendly because it reuses the frame instead of explicitly passing state, but it is going to be a real strain on the event loop (unless we implement it in
callbacks.Callback.__call__
? or maybe a new plugin class incallbacks
? or even make it an external library that defines a abstract callback class that plugins can inherit to use async?)