feat(lib): add package-level functions #208
Merged
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.
Description
Similar to some packages of the standard libarary (e.g. log) Notify now has a global but private standard instance that gets created on initialization. This is more of a convenience feature as it potentially saves a single step when interacting with Notify. Functions like
UseServices
andSend
are now usable directly from the package. Think of how you can uselog.Print(...)
directly but can also create and use a logger instance withlog.New(...)
.In the following we assume that
s
is a fully initialized Notify service.Example(old):
Example(new):
Of course the function
New
still exists! This is a non-breaking change that, in a sense, just adds some syntactic-sugar.Motivation and Context
Make the interaction with Notify optionally easier and more intuitiv.
How Has This Been Tested?
Wrote a small tool that uses my local version of Notify, created some services and send messages through them.
Screenshots / Output (if appropriate):
Types of changes
Checklist: