GeezerVison is showing github.com — rework event handling and rework how extensions are set up by akiraveliara · Pull Request #2045 · DSharpPlus/DSharpPlus
Conversation
- removes corelib dependence on AsyncEvent`2 for dispatching events and instead replaces it with a type-agnostic dispatcher assuming immutable events (removing most of the cruft from AsyncEvent`2 is also nice for perf)
- enables event handlers expressed as types by implementing
IEventHandler<TEventArgs>. these can be registered using EventHandlingBuilder.AddEventHandlers<T>(ServiceLifetime); a type can contain an indefinite amount of handlers and the type will have a respected service lifetime according to the parameter.
- fixes a memory leak in Interactivity
- interactivity generally is rather janky and remains rather janky here
- changes every extension setup to be along the lines of
IServiceCollection.AddExtension(Action<Extension> setup, ExtensionConfiguration);, with matching methods on DiscordClientBuilder, following an UseExtension scheme according to past convention (open to changing this).
- the
setup parameter fills the need for calling additional configuration on the extension, so for example the following code would be refactored as follows
- in the future, extensions fully supported throughout the v5 lifecycle should add first-class support without needing a
setup parameter
// old
DiscordClientBuilder builder = // we get a client here;
DiscordClient client = builder.Build();
CommandsExtension extension = client.UseCommands(myConfig);
extension.AddCommands([typeof(Command)]);
extension.AddConverters(...);
await client.ConnectAsync();
// new
DiscordClientBuilder builder = // we get a client here;
builder.UseCommands(extension =>
{
extension.AddCommands([typeof(MyCommand)]);
extension.AddConverters(...);
},
myConfig
);
await builder.ConnectAsync();
closes #1820 as complete
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
OoLunar reacted with thumbs up emoji
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.
Generally LGTM. Some discussion points but nothing major. Ping me in the server if you want to discuss any.
Seems ready for testing, at least.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
|
tested, documented, should be rtm as far as i'm concerned
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Overall looks good! Some small things I caught at a glance, but this is definitely a huge step forward.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
OoLunar
pushed a commit
that referenced
this pull request
Oct 3, 2024
* implement canonicalization of events and rewire Dispatch
* this is miserable
* remove legacy event hooks
* type safety is an obstacle /s
* CommandsNext
* VoiceNext
* SlashCommands
* lavalink is dead, so just make sure it compiles
* actually remove the old event handling code
* interactivity support
* update tests
* delete legacy BaseExtension
* internal convenience for interactivity
* make the extensions disposable
* shaking my head
* fix the return type
* this was solved differently in master
* update docs
* pr feedback
Instellate
pushed a commit
that referenced
this pull request
Nov 4, 2024
* implement canonicalization of events and rewire Dispatch
* this is miserable
* remove legacy event hooks
* type safety is an obstacle /s
* CommandsNext
* VoiceNext
* SlashCommands
* lavalink is dead, so just make sure it compiles
* actually remove the old event handling code
* interactivity support
* update tests
* delete legacy BaseExtension
* internal convenience for interactivity
* make the extensions disposable
* shaking my head
* fix the return type
* this was solved differently in master
* update docs
* pr feedback
Reviewers
Naamloos
Naamloos approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Development
Successfully merging this pull request may close these issues.
v5 extensions and events design
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|