-
-
Notifications
You must be signed in to change notification settings - Fork 870
Added a section on Dependency Injection technology in documentation #1253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✔️ Changelog found.Thank you for adding a description of the changes |
@@ -0,0 +1,56 @@ | |||
###### |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#sections
Section headers (ref) are created by underlining (and optionally overlining) the section title with a punctuation character, at least as long as the text
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@@ -0,0 +1,56 @@ | |||
###### | |||
Dependency injection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so this is a clear dependency injection mechanism, but i don't know another name for this feature
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so this is a clear dependency injection mechanism
The basic concept of dependency injection is clearly visible in the example of passing a router to the current handler (by "event_router" keyword) - the handler itself depends on it and has access to it.
But you really can pass anything through the handling context and do it both at application startup and at runtime. 🧐
Nevertheless, I saw other libraries that also name the concept of passing arguments to the function by parameter names / type hints like "depends".
but i don't know another name for this feature
Maybe "Handling context"?
self, | ||
message: Message, | ||
event_from_user: User | ||
# as I said previously, filters also can accept keyword parameters like in handlers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"As I said previously" is not clear sentence for this place in due to example can be viewed without reading documentation and this comment is first in this file, you say nothing previously.
return False | ||
|
||
|
||
@router.message(HelloFilter(name=None)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name is optional argument, you shouldn't pass any balue to it
Description
I often noticed that developers ignored the existence of the concept of dependency injection, using global variables or singleton instead. Previously, this topic was not covered in the documentation, which I corrected.
Type of change
Checklist: