Skip to content

Commit

Permalink
fix(dash): loose threads causing bad card reloads
Browse files Browse the repository at this point in the history
  • Loading branch information
billyc committed Jul 20, 2021
1 parent 79d6d9d commit 90c74ed
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
12 changes: 6 additions & 6 deletions src/charts/area.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default class VueComponent extends Vue {
@Prop({ required: true }) files!: string[]
@Prop({ required: true }) config!: any
private solverThread!: any
private thread!: any
private dataRows: any[] = []
private async mounted() {
Expand All @@ -29,12 +29,12 @@ export default class VueComponent extends Vue {
private async loadData() {
if (!this.files.length) return
if (!this.solverThread) {
this.solverThread = await spawn(new Worker('../workers/DataFetcher.thread'))
}
// cancel any loose threads first
if (this.thread) Thread.terminate(this.thread)
this.thread = await spawn(new Worker('../workers/DataFetcher.thread'))
try {
const data = await this.solverThread.fetchData({
const data = await this.thread.fetchData({
fileSystemConfig: this.fileSystemConfig,
subfolder: this.subfolder,
files: this.files,
Expand All @@ -48,7 +48,7 @@ export default class VueComponent extends Vue {
console.log(message)
this.dataRows = []
} finally {
Thread.terminate(this.solverThread)
Thread.terminate(this.thread)
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/charts/choropleth-map.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ export default class VueComponent extends Vue {
}
private async loadDataset() {
if (!this.thread) {
this.thread = await spawn(new Worker('../workers/DataFetcher.thread'))
}
// cancel any loose threads first
if (this.thread) Thread.terminate(this.thread)
this.thread = await spawn(new Worker('../workers/DataFetcher.thread'))
try {
const data = await this.thread.fetchData({
Expand Down
11 changes: 5 additions & 6 deletions src/charts/pie.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default class VueComponent extends Vue {
@Prop({ required: true }) files!: string[]
@Prop({ required: true }) config!: any
private solverThread!: any
private thread!: any
private dataRows: any = {}
private async mounted() {
Expand All @@ -35,12 +35,11 @@ export default class VueComponent extends Vue {
private async loadData() {
if (!this.files.length) return
if (!this.solverThread) {
this.solverThread = await spawn(new Worker('../workers/DataFetcher.thread'))
}
if (this.thread) Thread.terminate(this.thread)
this.thread = await spawn(new Worker('../workers/DataFetcher.thread'))
try {
const data = await this.solverThread.fetchData({
const data = await this.thread.fetchData({
fileSystemConfig: this.fileSystemConfig,
subfolder: this.subfolder,
files: this.files,
Expand All @@ -54,7 +53,7 @@ export default class VueComponent extends Vue {
console.log(message)
this.dataRows = {}
} finally {
Thread.terminate(this.solverThread)
Thread.terminate(this.thread)
}
}
Expand Down

0 comments on commit 90c74ed

Please sign in to comment.