Examples with multiple classes, instead of a big "flat file"
See original GitHub issueThe files in the examples
directory are very helpful. Thank you for those!
Unfortunately (and please don’t take this the wrong) they aren’t very “Pythonic”. They all start by defining a global:
app = AsyncApp() # or App()
and then proceed to use the @app.message
, @app.event
, etc. syntactic sugar to decorate the event handlers being demonstrated. This is definitely a great way to introduce the concepts of Bolt, and it makes the examples easy to follow.
But I’d like to see a more “real world” example (or maybe two, if App()
and AsyncApp()
are substantially different) which demonstrates “Bolt-approved best practices” on how to split (unrelated) sections of an app’s event processing across multiple files/classes, and not have to rely on an app
global to decorate event handlers.
I’ve tried several approaches, but none of them feel very satisfying. Or perhaps I’m just missing something obvious? In any case, it would be great to see what the Bolt authors had in mind in terms of a “larger scale” app… even just a short example with some event handlers split across a couple files would be helpful. (Hopefully it wasn’t to just put everything in one flat namespace! 😄)
Thanks!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:7 (5 by maintainers)
This is what I came up with last night as a proof-of-concept. During dynamic loading of the plugins, I call in to a
register
method in each plugin to attach Bolt events:Do you foresee any problems with this approach? Thanks again.
Thanks @eddyg for the issue and @seratch for the answers. I’m in pretty much the exact same place – trying to modernize an app built on top of https://github.com/slackapi/python-rtmbot and was struggling with how to keep the generation modular. I was very glad to have run across this issue.