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
This PR improves the
Service
andServiceBroker
lifecycle handler type definitions in the following ways:Service Lifecycle Handlers
this
value of theService
. The type was updated to have athis
value of theService
.created
handler was not consistent in structure with thestarted
andstopped
handlers. Thecreated
handler was defined inline while thestarted
andstopped
handlers were aliased. This was adjusted so that both are now aliased.StartedStoppedHandler
type was rather specific in name, so to make it more generic it was renamed toServiceAsyncLifecycleHandler
. The counterpart for thecreated
handler was then aServiceSyncLifecycleHandler
. These can then be reused as necessary without any naming confusion.StartedStoppedHandler
to allow returningPromise<void[]>
. However, that is not the intent of these lifecycle methods -- they should returnvoid | Promise<void>
. Any other type being returned is not appropriate, includingPromise<void[]>
. The intent was to allow a return ofPromise.all[...]
but the preferred approach would be something like:Broker Lifecycle Handlers
The main issue with the broker lifecycle handlers is that the
started
andstopped
handlers do not allow returningPromise<void>
and are expecting a return ofvoid
. Changes have been made to address that deficiency as well as make the types used consistent with the changes that were just made to the service lifecycle handlers.Other Changes
Any other changes were unintentional and only a result of prettier auto-formatting making adjustments.
💎 Type of change
🚦 How Has This Been Tested?
Created a test repo and set it up to work with these type changes. Confirmed the following:
started
andstopped
handlers now allow passing a Promise returning function.created
,started
, andstopped
handlers now inferthis
as theService
type rather than theServiceSchema
type.🏁 Checklist: