Skip to content

Commit

Permalink
view: recompute subscription on query change
Browse files Browse the repository at this point in the history
* If a view's query changes (e.g. if its variables change) whilst it is
  running. The view will now be un-subscribed, then re-subscribed with
  the new query.
  • Loading branch information
oliver-sanders committed Dec 9, 2022
1 parent c8bedc3 commit 4841f6a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/mixins/subscriptionComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import subscriptionMixin from '@/mixins/subscription'
* of such component is the GScan component, which declares a query used to
* list the workflows of the system in the UI sidebar.
*
* Uses Vue component lifecycle methods (e.g. created, beforeDestroy) to coordinate
* when a subscription is created in the WorkflowService service.
* Uses Vue component lifecycle methods (e.g. created, beforeDestroy) to
* coordinate when a subscription is created in the WorkflowService service.
*
* @see Subscription
* @see SubscriptionQuery
Expand All @@ -38,5 +38,13 @@ export default {
},
beforeDestroy () {
this.$workflowService.unsubscribe(this)
},
watch: {
query (query) {
console.error('QUERY CHANGED')
// if the query changes, unsubscribe & re-subscribe
this.$workflowService.unsubscribe(this)
this.$workflowService.subscribe(this)
}
}
}

0 comments on commit 4841f6a

Please sign in to comment.