Skip to content

Commit 1d0994d

Browse files
authored
Merge pull request #1 from feathersjs-ecosystem/master
Sync with master
2 parents 02322ed + c75b3e4 commit 1d0994d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+26467
-1036
lines changed

.vscode/settings.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@
88
"lib/**": true,
99
"**/node_modules": true,
1010
"**/bower_components": true,
11-
"**/yarn.lock": true
11+
"**/yarn.lock": true,
12+
"**/package-lock.json": true
1213
},
1314
"workbench.colorCustomizations": {
1415
"activityBar.background": "#2B3011",
1516
"titleBar.activeBackground": "#3C4418",
1617
"titleBar.activeForeground": "#FAFBF4"
17-
}
18+
},
19+
"editor.defaultFormatter": "esbenp.prettier-vscode",
20+
"prettier.arrowParens": "avoid",
21+
"javascript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": false
1822
}

docs/2.0-major-release.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ I have not been able to find a diffing algorithm that works equally well acroos
163163

164164
## Model Classes: BYOD (Bring Your Own Diffing)
165165

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+
166168
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.
167169

168170
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`.

docs/3.0-major-release.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@ Version 3.0 of Feathers-Vuex is the Vue Composition API release! There were qui
1616

1717
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).
1818

19+
## Partial data on patch <Badge text="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:
21+
22+
```js
23+
import { models } from 'feathers-vuex'
24+
const { Todo } = models.api
25+
26+
const todo = new Todo({ description: 'Do Something', isComplete: false })
27+
28+
todo.patch({ data: { isComplete: true } })
29+
30+
// also works for patching with instance.save
31+
todo.save({ data: { isComplete: true } })
32+
```
33+
1934
## FeathersVuexPagination Component <Badge text="3.8.0+" />
2035

2136
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).
@@ -69,14 +84,18 @@ This behavior exactly matches the new `useFind` utility.
6984

7085
## Deprecations
7186

72-
### The `keepCopiesInStore` Option<Badge text="deprecated" type="warning"/>
87+
### The `keepCopiesInStore` Option <Badge text="deprecated" type="warning"/>
7388

7489
The `keepCopiesInStore` option is now deprecated. This was a part of the "clone and commit" API which basically disabled the reason for creating the "clone and commit" API in the first place.
7590

7691
If you're not familiar with the Feathers-Vuex "clone and commit" API, you can learn more about the [built-in data modeling](./model-classes.md) API and the section about [Working with Forms](./feathers-vuex-forms.md#the-clone-and-commit-pattern).
7792

7893
The `keepCopiesInStore` feature is set to be removed in Feathers-Vuex 4.0.
7994

80-
### Auth Plugin State: `user`<Badge text="deprecated" type="warning"/>
95+
### Auth Plugin State: `user` <Badge text="deprecated" type="warning"/>
8196

8297
As described, earlier on this page, since the Auth Plugin's `user` state is no longer reactive and has been replaced by a `user` getter that IS reactive, the `user` state will be removed in the Feathers-Vuex 4.0.
98+
99+
### Renderless Data Components: `query`, `fetchQuery` and `temps` <Badge text="deprecated type="warning">
100+
101+
To keep consistency with mixins and the composition API it's preferred to use `params` and `fetchParams` instead of the old `query` and `fetchQuery` for renderless data components. Also the `:temps="true"` is deprecated in favour of `:params="{ query: {}, temps: true }"`. This way additional params can be passed to the server if you need some more magic like `$populateParams`.

docs/common-patterns.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ class Post extends BaseModel {
278278

279279
## Relationships for Populated Data
280280

281+
If you're looking for a great solution for populating data to work with Feathers-Vuex, check out [feathers-graph-populate](https://feathers-graph-populate.netlify.app/).
282+
281283
A common task with almost any API is properly handling relationships between endpoints. Imagine an API where you have `/todos` and `/users` services. Each todo record can belong to a single user, so a todo has a `userId`.
282284

283285
```js

docs/composition-api.md

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ interface UseFindOptions {
105105
fetchParams?: Params | Ref<Params>
106106
queryWhen?: Ref<Function>
107107
qid?: string
108-
lazy?: boolean
108+
immediate?: boolean
109109
}
110110
```
111111

@@ -123,7 +123,7 @@ And here's a look at each individual property:
123123
- Explicitly returning `null` will prevent an API request from being made.
124124
- `queryWhen` must be a `computed` property which returns a `boolean`. It provides a logical separation for preventing API requests *outside* of the `params`.
125125
- `qid` allows you to specify a query identifier (used in the pagination data in the store). This can also be set dynamically by returning a `qid` in the params.
126-
- `lazy`, which is `false` by default, determines if the internal `watch` should fire immediately. Set `lazy: true` and the query will not fire immediately. It will only fire on subsequent changes to the params.
126+
- `immediate`, which is `true` by default, determines if the internal `watch` should fire immediately. Set `immediate: false` and the query will not fire immediately. It will only fire on subsequent changes to the params.
127127

128128
### Returned Attributes
129129

@@ -150,8 +150,8 @@ Let's look at the functionality that each one provides:
150150

151151
- `items` is the list of results. By default, this list will be reactive, so if new items are created which match the query, they will show up in this list automagically.
152152
- `servicePath` is the FeathersJS service path that is used by the current model. This is mostly only useful for debugging.
153-
- `isFindPending` is a boolean that indicates if there is an active query. It is set to `true` just before each outgoing request. It is set to `false` after the response returns. Bind to it in the UI to show an activity indicator to the user.
154-
- `haveBeenRequestedOnce` is a boolean that is set to `true` immediately before the first query is sent out. It remains true throughout the life of the component. This comes in handy for first-load scenarios in the UI.
153+
- `isPending` is a boolean that indicates if there is an active query. It is set to `true` just before each outgoing request. It is set to `false` after the response returns. Bind to it in the UI to show an activity indicator to the user.
154+
- `haveBeenRequested` is a boolean that is set to `true` immediately before the first query is sent out. It remains true throughout the life of the component. This comes in handy for first-load scenarios in the UI.
155155
- `haveLoaded` is a boolean that is set to true after the first API response. It remains `true` for the life of the component. This also comes in handy for first-load scenarios in the UI.
156156
- `isLocal` is a boolean that is set to true if this data is local only.
157157
- `qid` is currently the primary `qid` provided in params. It might become more useful in the future.
@@ -208,7 +208,7 @@ If you have already used the `makeFindMixin`, the `useFind` composition function
208208

209209
1. `useFind` is more TypeScript friendly. Since the mixins depended on adding dynamic attribute names that wouldn't overlap, TypeScript tooling and autocomplete weren't very effective. The attributes returned from `useFind` are always consistent.
210210
1. Instead of providing a service name, you provide a service Model from the `$FeathersVuex` Vue plugin.
211-
1. The default behavior of `useFind` is to immediately query the API server. The `makeFindMixin`, by default, would wait until the watcher noticed the change. This is to match the default behavior of `watch` in the Vue Composition API. You can pass `{ lazy: true }` in the `useFind` options, which will be passed directly to the internal `watch` on the params.
211+
1. The default behavior of `useFind` is to immediately query the API server. The `makeFindMixin`, by default, would wait until the watcher noticed the change. This is to match the default behavior of `watch` in the Vue Composition API. You can pass `{ immediate: false }` in the `useFind` options, which will be passed directly to the internal `watch` on the params.
212212

213213
Note that with the Vue Options API (aka the only way to write components in Vue 2.0) the models are found in `this.$FeathersVuex`. With the Vue Composition API, this object is now at `context.root.$FeathersVuex`.
214214

@@ -268,7 +268,7 @@ interface UseGetOptions {
268268
params?: Params | Ref<Params>
269269
queryWhen?: Ref<Function>
270270
local?: boolean
271-
lazy?: boolean
271+
immediate?: boolean
272272
}
273273
```
274274
@@ -281,7 +281,7 @@ And here's a look at each individual property:
281281
- `params` is a FeathersJS Params object OR a Composition API `ref` (or `computed`, since they return a `ref` instance) which returns a Params object.
282282
- Unlike the `useFind` utility, `useGet` does not currently have built-in debouncing.
283283
- `queryWhen` must be a `computed` property which returns a `boolean`. It provides a logical separation for preventing API requests apart from `null` in the `id`.
284-
- `lazy`, which is `false` by default, determines if the internal `watch` should fire immediately. Set `lazy: true` and the query will not fire immediately. It will only fire on subsequent changes to the `id` or `params`.
284+
- `immediate`, which is `true` by default, determines if the internal `watch` should fire immediately. Set `immediate: false` and the query will not fire immediately. It will only fire on subsequent changes to the `id` or `params`.
285285
286286
### Returned Attributes
287287
@@ -779,6 +779,21 @@ export default new Router({
779779

780780
Now, the `Post.vue` file only requires to have a `prop` named `id`. Vue Router will pass the params from the route as props to the component. See the [first useGet example](#useget) for a component that would work with the above route. The vue-router documentation has more information about [Passing Props to Route Components](https://router.vuejs.org/guide/essentials/passing-props.html#passing-props-to-route-components)
781781

782+
### Composing with Model types
783+
784+
Both `useGet` and `useFind` have an optional type parameter for the Model type which is used as the type for the returned item(s).
785+
786+
```ts
787+
// Destructure Model class from global models object
788+
const { User } = Vue.$FeathersVuex.api
789+
790+
// use useGet with User Model
791+
useGet<typeof User.prototype>(/* ... */)
792+
793+
// use useFind with User Model
794+
useFind<typeof User.prototype>(/* ... */)
795+
```
796+
782797
## Conventions for Development
783798

784799
### Params are Computed

0 commit comments

Comments
 (0)