Skip to content

Commit

Permalink
fix(react-hooks): fix service tracker initial service detection
Browse files Browse the repository at this point in the history
  • Loading branch information
noherczeg committed Feb 27, 2023
1 parent 54f7ffb commit 154f0d6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/@pandino/react-hooks/src/useTrackService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ export const useTrackService: ServiceTrackerHook = <T>(filter: string) => {
});

useEffect(() => {
const refs = bundleContext.getServiceReferences<T>(undefined, filter);

if (refs && refs.length) {
const svc = bundleContext.getService<T>(refs[0]);
setTracker({
service: svc,
});
}

const serviceTracker = bundleContext.trackService(filter, {
addingService(reference: ServiceReference<T>): T {
const service = bundleContext.getService<T>(reference);
Expand Down

0 comments on commit 154f0d6

Please sign in to comment.