Skip to content

Commit 9fb63a4

Browse files
authored
docs: add readme (#39)
closes #2
1 parent 8a5111f commit 9fb63a4

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Vue.js compositions for Feathers
2+
3+
Provides `get` and `find` compositions that let you query your feathers API.
4+
Queries and responses are fully reactive allowing you to:
5+
6+
- trigger a query by simply updating a query parameter
7+
- receive continuous updates via [@feathersjs/socketio-client](https://docs.feathersjs.com/api/client/socketio.html) that are instantly visible inside Vue components.
8+
9+
## Example usage
10+
11+
Define a wrapper that passes your feathers app.
12+
Passing your `Application` type including your `ServiceTypes` allows typechecking of the `serviceName` parameter.
13+
14+
```ts
15+
// useFindWrapper.ts
16+
import { useFind } from '@geprog/use-feathers';
17+
import { Application as FeathersApplication } from '@feathersjs/feathers';
18+
import { AdapterService } from '@feathersjs/adapter-commons';
19+
import { Car } from './model';
20+
21+
type ServiceTypes = {
22+
cars: AdapterService<Car>;
23+
};
24+
25+
type Application = FeathersApplication<ServiceTypes>;
26+
27+
export const useFindWrapper = useFind<Application>(yourFeathersApp);
28+
```
29+
30+
Inside a Vue component call the wrapper with a `serviceName` and a Params ref containing your query.
31+
32+
```ts
33+
import { computed, defineComponent } from 'vue';
34+
import { useFindWrapper } from './useFindWrapper';
35+
36+
export default defineComponent({
37+
setup() {
38+
const seats = ref(4);
39+
const { data: cars, isLoading } = useFindWrapper(
40+
'cars',
41+
computed(() => ({ paginate: false, query: { seats: seats.value } })),
42+
);
43+
return { seats, cars, isLoading };
44+
},
45+
});
46+
```

0 commit comments

Comments
 (0)