Skip to content

Improve HttpClient Usage #7

Closed
Closed

Description

@nikmd23

Hello!

I'm a big fan of this library, and I'm glad that there's a .NET solution for web push.

I was looking through the source code, and I noticed an easy to stumble into code smell in the SendNotification implementation: a new HttpClient is created for each notification sent.

There's a good article explaining why this is bad, and how to fix it.

Activity

  1. added a commit that references this issue on Feb 24, 2017
  2. coryjthompson commented on Mar 6, 2017

    @coryjthompson
    Member

    Thank you for the great feedback @nikmd23, I was unaware of this!

    I'm now using a shared instance pf HttpClient within my class which doesn't "solve" the issue however it allows the user to hold a static instance to my class which resolves the issue.

    Does this fix the issue for you?

    I wasn't too keen to store an HttpClient object after my class was disposed just in case i need it again.

  3. self-assigned this
    on Mar 6, 2017
  4. added this to the 1.0.9 milestone on Mar 6, 2017
  5. nikmd23 commented on Mar 6, 2017

    @nikmd23
    Author

    Sounds like a great improvement @coryjthompson. Thanks!

    PS - I'm in the middle of recording a Pluralsight course on WebPush. In it, I'm both using and recommending your library! It worked great and was just what I needed.

  6. coryjthompson commented on Mar 6, 2017

    @coryjthompson
    Member

    Wow! Thank you, that is awesome. Would you mind sending a link once its published?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions