From 04891de3a59204a0120ddd064615b2ed4062077a Mon Sep 17 00:00:00 2001 From: Guillaume Chau Date: Tue, 21 May 2019 13:57:49 +0200 Subject: [PATCH] feat(components): loading event --- docs/api/apollo-mutation.md | 1 + docs/api/apollo-query.md | 1 + src/components/ApolloMutation.js | 6 ++++++ src/components/ApolloQuery.js | 4 ++++ 4 files changed, 12 insertions(+) diff --git a/docs/api/apollo-mutation.md b/docs/api/apollo-mutation.md index a209ddd0..117ffe9e 100644 --- a/docs/api/apollo-mutation.md +++ b/docs/api/apollo-mutation.md @@ -45,3 +45,4 @@ Example: - `done(resultObject)` - `error(errorObject)` +- `loading(boolean)` diff --git a/docs/api/apollo-query.md b/docs/api/apollo-query.md index 4c02a678..116adb87 100644 --- a/docs/api/apollo-query.md +++ b/docs/api/apollo-query.md @@ -65,3 +65,4 @@ To enable support of `gql` string tag in Vue templates, see the necessary setup - `result(resultObject)` - `error(errorObject)` +- `loading(boolean)` diff --git a/src/components/ApolloMutation.js b/src/components/ApolloMutation.js index 3d9e1811..b03ebc29 100644 --- a/src/components/ApolloMutation.js +++ b/src/components/ApolloMutation.js @@ -46,6 +46,12 @@ export default { } }, + watch: { + loading (value) { + this.$emit('loading', value) + }, + }, + methods: { mutate (options) { this.loading = true diff --git a/src/components/ApolloQuery.js b/src/components/ApolloQuery.js index d46004d3..0fba4715 100644 --- a/src/components/ApolloQuery.js +++ b/src/components/ApolloQuery.js @@ -116,6 +116,10 @@ export default { notifyOnNetworkStatusChange: value, }) }, + + '$data.$apolloData.loading' (value) { + this.$emit('loading', !!value) + }, }, apollo: {