bugfix: improve reactivity

This commit is contained in:
Matthieu Fesselier 2021-05-19 10:25:10 +02:00
parent d1dc13fef1
commit 83a02135fc
4 changed files with 18 additions and 14 deletions

View File

@ -15,6 +15,9 @@ export const HublReactivity = {
this.subscribe();
}
},
refreshData: {
type: String,
},
},
async fetchData(value) {
this.resourceId = null;
@ -28,9 +31,10 @@ export const HublReactivity = {
this.subscribe();
},
subscribe() {
if (this.resourceId && this.targetSrc) {
if (this.refreshData === '') { // clears cache and re-fetch data
store.subscribeVirtualContainerTo(this.resourceId, this.targetSrc);
store.subscribeVirtualContainerTo(this.targetSrc, this.resourceId);
} else { // notifies components
store.subscribeResourceTo(this.resourceId, this.targetSrc);
}
}
}

View File

@ -16,8 +16,8 @@ solid-widget(name=`hubl-admin-circle-join-button`)
hubl-reactivity(data-src=`${getComponent('circles').endpoints.get}` target-src='${value}')
hubl-reactivity(data-src=`${getComponent('circles').endpoints.get}joinable/` target-src='${value}')
hubl-reactivity(data-src=`${getComponent('circles').endpoints.post}` target-src='${value}')
hubl-reactivity(data-src=`${getComponent('circles').endpoints.post}joinable/` target-src='${value}')
hubl-reactivity(bind-user nested-field="circles" target-src='${value}')
hubl-reactivity(data-src=`${getComponent('circles').endpoints.post}joinable/` target-src='${value}' refresh-data)
hubl-reactivity(bind-user nested-field="circles" target-src='${value}' refresh-data)
include page-admin-circles.pug

View File

@ -3,8 +3,8 @@ solid-widget(name=`leave-circle-reactivity`)
hubl-reactivity(data-src=`${getComponent('circles').endpoints.get}` target-src='${value}')
hubl-reactivity(data-src=`${getComponent('circles').endpoints.get}joinable/` target-src='${value}')
hubl-reactivity(data-src=`${getComponent('circles').endpoints.post}` target-src='${value}')
hubl-reactivity(data-src=`${getComponent('circles').endpoints.post}joinable/` target-src='${value}')
hubl-reactivity(bind-user nested-field="circles" target-src='${value}')
hubl-reactivity(data-src=`${getComponent('circles').endpoints.post}joinable/` target-src='${value}' refresh-data)
hubl-reactivity(bind-user nested-field="circles" target-src='${value}' refresh-data)
solid-widget(name=`hubl-admin-circle-leave-button`)
template
@ -17,8 +17,8 @@ solid-widget(name=`hubl-admin-circle-leave-button`)
hubl-reactivity(data-src=`${getComponent('circles').endpoints.get}` target-src='${src}')
hubl-reactivity(data-src=`${getComponent('circles').endpoints.get}joinable/` target-src='${src}')
hubl-reactivity(data-src=`${getComponent('circles').endpoints.post}` target-src='${src}')
hubl-reactivity(data-src=`${getComponent('circles').endpoints.post}joinable/` target-src='${src}')
hubl-reactivity(bind-user nested-field="circles" target-src='${src}')
hubl-reactivity(data-src=`${getComponent('circles').endpoints.post}joinable/` target-src='${src}' refresh-data)
hubl-reactivity(bind-user nested-field="circles" target-src='${src}' refresh-data)
solid-display(
data-src="${src}"
fields="circle"

View File

@ -43,8 +43,8 @@ div.segment.full.padding-large.sm-padding-xsmall.sm-padding-top-medium.whitespac
hubl-reactivity(data-src=`${getComponent('projects').endpoints.get}` target-src='${value}')
hubl-reactivity(data-src=`${getComponent('projects').endpoints.get}joinable/` target-src='${value}')
hubl-reactivity(data-src=`${getComponent('projects').endpoints.post}` target-src='${value}')
hubl-reactivity(data-src=`${getComponent('projects').endpoints.post}joinable/` target-src='${value}')
hubl-reactivity(bind-user nested-field="projects" target-src='${value}')
hubl-reactivity(data-src=`${getComponent('projects').endpoints.post}joinable/` target-src='${value}' refresh-data)
hubl-reactivity(bind-user nested-field="projects" target-src='${value}' refresh-data)
solid-widget(name=`hubl-admin-project-leave-button`)
template
@ -57,8 +57,8 @@ div.segment.full.padding-large.sm-padding-xsmall.sm-padding-top-medium.whitespac
hubl-reactivity(data-src=`${getComponent('projects').endpoints.get}` target-src='${src}')
hubl-reactivity(data-src=`${getComponent('projects').endpoints.get}joinable/` target-src='${src}')
hubl-reactivity(data-src=`${getComponent('projects').endpoints.post}` target-src='${src}')
hubl-reactivity(data-src=`${getComponent('projects').endpoints.post}joinable/` target-src='${src}')
hubl-reactivity(bind-user nested-field="projects" target-src='${src}')
hubl-reactivity(data-src=`${getComponent('projects').endpoints.post}joinable/` target-src='${src}' refresh-data)
hubl-reactivity(bind-user nested-field="projects" target-src='${src}' refresh-data)
solid-display(
data-src="${src}"
fields="project"
@ -122,8 +122,8 @@ div.segment.full.padding-large.sm-padding-xsmall.sm-padding-top-medium.whitespac
hubl-reactivity(data-src=`${getComponent('projects').endpoints.get}` target-src='${value}')
hubl-reactivity(data-src=`${getComponent('projects').endpoints.get}joinable/` target-src='${value}')
hubl-reactivity(data-src=`${getComponent('projects').endpoints.post}` target-src='${value}')
hubl-reactivity(data-src=`${getComponent('projects').endpoints.post}joinable/` target-src='${value}')
hubl-reactivity(bind-user nested-field="projects" target-src='${value}')
hubl-reactivity(data-src=`${getComponent('projects').endpoints.post}joinable/` target-src='${value}' refresh-data)
hubl-reactivity(bind-user nested-field="projects" target-src='${value}' refresh-data)
solid-display(
class='table-body'