Skip to content

Commit 9368502

Browse files
authored
feat!: pass feathers params through useGet (#63)
BREAKING CHANGE: empty params need to be specified if disableUnloadingEventHandlers is used
1 parent d25dfba commit 9368502

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/useGet.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Application, FeathersService, Id, ServiceMethods } from '@feathersjs/feathers';
1+
import type { Application, FeathersService, Id, Params, ServiceMethods } from '@feathersjs/feathers';
22
import { onBeforeUnmount, onMounted, Ref, ref, watch } from 'vue';
33

44
import { getId, ServiceModel, ServiceTypes } from './utils';
@@ -71,6 +71,7 @@ export default <CustomApplication extends Application>(feathers: CustomApplicati
7171
<T extends keyof ServiceTypes<CustomApplication>, M = ServiceModel<CustomApplication, T>>(
7272
serviceName: T,
7373
_id: Ref<Id | undefined | null>,
74+
params: Ref<Params | undefined> = ref(),
7475
{ disableUnloadingEventHandlers } = { disableUnloadingEventHandlers: false },
7576
): UseGet<M> => {
7677
const data = ref<M>();
@@ -89,7 +90,7 @@ export default <CustomApplication extends Application>(feathers: CustomApplicati
8990
}
9091
// TODO: the typecast below is necessary due to the prerelease state of feathers v5. The problem there is
9192
// that the AdapterService interface is not yet updated and is not compatible with the ServiceMethods interface.
92-
data.value = await (service as unknown as ServiceMethods<M>).get(_id.value);
93+
data.value = await (service as unknown as ServiceMethods<M>).get(_id.value, params.value);
9394
isLoading.value = false;
9495
};
9596

test/useGet.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ describe('Get composition', () => {
537537
const useGet = useGetOriginal(feathersMock);
538538
let getComposition = null as UseGet<TestModel> | null;
539539
const wrapper = mountComposition(() => {
540-
getComposition = useGet('testModels', ref(testModel._id), { disableUnloadingEventHandlers: true });
540+
getComposition = useGet('testModels', ref(testModel._id), ref(), { disableUnloadingEventHandlers: true });
541541
});
542542

543543
// when

0 commit comments

Comments
 (0)