You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/2.0-major-release.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -163,6 +163,8 @@ I have not been able to find a diffing algorithm that works equally well acroos
163
163
164
164
## Model Classes: BYOD (Bring Your Own Diffing)
165
165
166
+
> Note: As of `[email protected]`, you can also pass `params.data` to the patch object to implement partial patching on objects. You might choose to use `params.data` instead of `diffOnPatch`.
167
+
166
168
First, why do any diffing? On the API server, an `update` request replaces an entire object, but a `patch` request only overwrites the attributes that are provided in the data. For services with simple schemas, it doesn't really matter. But if your schema grows really large, it can be supportive to only send the updates instead of the entire object.
167
169
168
170
A new `diffOnPatch` method is available to override in your extended models. `diffOnPatch` gets called just before sending the data to the API server. It gets called with the data and must return the diffed data. By default, it is set to `diffOnPatch: data => data`.
Copy file name to clipboardExpand all lines: docs/3.0-major-release.md
+19Lines changed: 19 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,25 @@ Version 3.0 of Feathers-Vuex is the Vue Composition API release! There were qui
16
16
17
17
And now it has become the best way to perform queries with Feathers-Vuex. To find out how to take advantage of the new functionality in your apps, read the [Feather-Vuex Composition API docs](./composition-api.md).
18
18
19
+
## Partial data on patch <Badgetext="3.9.0+" />
20
+
As of version 3.9.0, you can provide an object as `params.data`, and Feathers-Vuex will use `params.data` as the patch data. This change was made to the service-module, itself, so it will work for `patch` across all of feathers-vuex. Here's an example of patching with partial data:
To assist with Server Side Pagination support, Feathers-Vuex now includes the `<FeathersVuexPagination>` component. It's a renderless component that removes the boilerplate behind handling pagination in the UI. Read about it in the [Composition API Docs](/composition-api.html#feathersvuexpagination).
37
+
19
38
## Custom Handling for Feathers Events <Badgetext="3.1.0+" />
20
39
21
40
Version 3.1 of Feathers-Vuex enables ability to add custom handling for each of the FeathersJS realtime events. You can read more about it in the [Service Plugin: Events](./service-plugin.md#service-events) docs.
Copy file name to clipboardExpand all lines: docs/common-patterns.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ You can set `debug: true` in the options to enable some logging to assist with d
12
12
13
13
## Use the `<FeathersVuexFind>` and `<FeathersVuexGet>` components
14
14
15
-
Using the new `<FeathersVuexFind>` and `<FeathersVuexGet>` components provides concise access to the best features of `feathers-vuex`, including live queries, reactive lists, custom pagination tracking per component, and fall-through cacheing of local data in the Vuex store. Check out the [Renderless Data Components](./components.html) docs for more details.
15
+
Using the new `<FeathersVuexFind>` and `<FeathersVuexGet>` components provides concise access to the best features of `feathers-vuex`, including live queries, reactive lists, custom pagination tracking per component, and fall-through cacheing of local data in the Vuex store. Check out the [Renderless Data Components](./data-components.html) docs for more details.
16
16
17
17
## Use the `makeFindMixin` and `makeGetMixin` utilities
Copy file name to clipboardExpand all lines: docs/composition-api.md
+215-6Lines changed: 215 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -132,16 +132,16 @@ Notice the `tutorialsData` in the previous example. You can see that there's an
132
132
```ts
133
133
interfaceUseFindData {
134
134
items:Ref<any>
135
+
paginationData:Ref<object>
135
136
servicePath:Ref<string>
136
-
isFindPending:Ref<boolean>
137
-
haveBeenRequestedOnce:Ref<boolean>
138
-
haveLoaded:Ref<boolean>
139
-
isLocal:Ref<boolean>
140
137
qid:Ref<string>
138
+
isPending:Ref<boolean>
139
+
haveBeenRequested:Ref<boolean>
140
+
haveLoaded:Ref<boolean>
141
+
error:Ref<Error>
141
142
debounceTime:Ref<number>
142
143
latestQuery:Ref<object>
143
-
paginationData:Ref<object>
144
-
error:Ref<Error>
144
+
isLocal:Ref<boolean>
145
145
find:Function
146
146
}
147
147
```
@@ -298,6 +298,215 @@ interface UseGetData {
298
298
}
299
299
```
300
300
301
+
## FeathersVuexPagination
302
+
303
+
As of version `3.8.0`, Feathers-Vuex includes the `FeathersVuexPagination` renderless component. This component pairs with the [`useFind` utility](#usefind) to simplify handling server-side pagination. If you use the FeathersVuex Vue plugin, the `FeathersVuexPagination` component is registered as a global component. Since it's a renderless component, you'll need to supply your own UI to the default slot.
304
+
305
+
### Usage Steps
306
+
307
+
The steps to using the `FeathersVuexPagination` component include
308
+
309
+
1. Create a `pagination` ref containing an object with `$limit` and `$skip` properties.
310
+
2. Create a `params` computed property. Be sure to include a `query` object and `paginate:true` in the params. It's also recommended that you use a `qid` to identify the component that you're using, otherwise pagination data could mix with other parts of the UI and create an inconsistent experience.
311
+
3. Merge the `pagination` into the `params.query`.
312
+
4. Pass the `params` object to the `useFind` utility.
313
+
5. Pull the `items` array and `latestQuery` object from `useFind`'s return value.
314
+
6. Make the `items`, `latestQuery`, and `pagination` available to the component's template by returning them in the setup method.
315
+
7. Provide the above two variables to the `FeathersVuexPagination` component as props.
316
+
8. Provide a UI inside the default slot, binding to variables and desired events.
317
+
318
+
### Props
319
+
320
+
The `FeathersVuexPagination` component only accepts two props.
321
+
322
+
- `v-model` (or `value`): Receives the `pagination` object, which must contain the `$limit` and `$skip` properties.
323
+
- `latest-query`, which receives the `latestQuery` object returned by the `useFind` utility.
324
+
325
+
### Default Slot Scope
326
+
327
+
The following variables and functions are provided by the default slot:
328
+
329
+
- `currentPage` {Number} The current page number, based on the current `$limit` and `$skip` values provided to the `v-model`.
330
+
- `pageCount` {Number} If the response from the API server includes a `total` attribute, the `pageCount` will be the total number of pages, based on the current value of `$limit`.
331
+
- `canPrev` {Boolean} Will be true if not on the first page (can go to a previous page). This value is useful for enabling/disabling a button in the UI, if you desire to give that kind of feedback to the user.
332
+
- `canNext` {Boolean} Will be true if not on the last page (can go to a next page). This value is useful for enabling/disabling a button in the UI, if you desire to give that kind of feedback to the user.
333
+
- `toStart` {Function} When called, will move to the first page.
334
+
- `toEnd` {Function} When called, will move to the last page.
335
+
- `toPage(n: number)` {Function} When called with a page number as its first argument, will move to that page number. If the page number is greater than the total number of pages, will go to the last page. If the page number is less than 0, will go to the first page.
336
+
- `prev` {Function} When called, moves to the previous page. Will not go below page 1.
337
+
- `next` {Function} When called, moves tot the next page. Will not go past the last page.
338
+
339
+
### Example
340
+
341
+
Here is an example of how to use it. It assumes that you have a `/listings` service with a `Listing` model. The next code example below this one shows the `PaginationUi` component. Note that not all slot scope variables and functions are required. To implement basic pagination, only the `currentPage`, `pageCount`, `next`, and `prev` values are really necessary. The other slot scope values allow providing a customized pagination experience.
As promised, here is the example code for the `PaginationUi` component used above. It includes some TailwindCSS utility classes in the markup in order to show how one might use the `canPrev` and `canNext` properties. Keep in mind that this is just an example. You can provide whatever experience you want for your users by creating your own component.
0 commit comments