Skip to content
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

v9: Added Extension method to register all custom Notifications #11199

Merged
merged 3 commits into from
Oct 18, 2021

Conversation

mclausen
Copy link
Member

Description

Let me ask you a question. How many tears have you felt, running down your chin, every-time you’d forgot to register your freshly created notification? How many times do you think you’d started the cms, and didn’t add your notifications? If you are like me, that is more than once, and that is too many.

What if i told you that you’d never had to forget to registers any custom notification handlers ever again, and that the solution would be helpful and friendly at the same time?

Enter this PR.

What does it do? It is an immediate pain reliever, that comes in a form of an Extension Method to IUmbracoBuilder named AddNotificationsFromAssembly<T> where T is the type within the assembly your or the customer custom notifications is located. It locates all your implementations of INotificationHandler<TNotification> and registers them in the IServiceCollector so you dont have to manually remember and add them your self.

How does it look in the wild?

You can add all notifications on One line

public class MyFavoriteComposer : IComposer
{
    public void Compose(IUmbracoBuilder builder)
    {
        builder.AddNotificationsFromAssembly<Startup>();
    }
}

Whatever custom notification that you have in your project will now be registered and the best thing is, that if you create a new one, then you no longer have to forget to register it.

Cheers 🍻

@mclausen mclausen changed the title Added Extension method to register all custom Notifications v9: Added Extension method to register all custom Notifications Sep 27, 2021
@bergmania bergmania added the state/sprint-candidate We're trying to get this in a sprint at HQ in the next few weeks label Oct 15, 2021
Copy link
Member

@Zeegaan Zeegaan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a few very minor things, rest of the code LGTM 👍

Tested this and it works great, never forgetting to register a notification again!
Will be happy to merge once the changes are made 💪

src/Umbraco.Core/Extensions/UmbracoBuilderExtensions.cs Outdated Show resolved Hide resolved
src/Umbraco.Core/Extensions/UmbracoBuilderExtensions.cs Outdated Show resolved Hide resolved
@mclausen
Copy link
Member Author

Thank you for the feedback @Zeegaan 🙌

@Zeegaan Zeegaan merged commit 434ce0f into v9/dev Oct 18, 2021
@Zeegaan Zeegaan deleted the register-notification-extension branch October 18, 2021 06:20
@Zeegaan
Copy link
Member

Zeegaan commented Oct 18, 2021

With the minor changes i am now happy to merge, great work 💪

@umbrabot umbrabot removed the state/sprint-candidate We're trying to get this in a sprint at HQ in the next few weeks label Oct 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants