Skip to content

Commit 8174e76

Browse files
committed
chore: useApplicationStore should not reset refs
1 parent eae2fed commit 8174e76

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

spring-boot-admin-server-ui/src/main/frontend/composables/useApplicationStore.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,40 @@ import { ref } from 'vue';
33
import ApplicationStore from '../store.js';
44

55
let applicationStore;
6+
const applications = ref([]);
7+
const applicationsInitialized = ref(false);
8+
const error = ref(null);
69

710
export function createApplicationStore() {
811
applicationStore = new ApplicationStore();
12+
console.log('createApplicationStore');
913
return applicationStore;
1014
}
1115

1216
export function useApplicationStore() {
13-
const applications = ref([]);
14-
const applicationsInitialized = ref(false);
15-
const error = ref(null);
16-
1717
applicationStore.addEventListener('connected', () => {
18+
console.log('connected');
1819
applicationsInitialized.value = true;
1920
error.value = null;
2021
});
2122

2223
applicationStore.addEventListener('changed', (newApplications) => {
24+
console.log('changed');
2325
applicationsInitialized.value = true;
2426
applications.value = newApplications;
2527
error.value = null;
2628
});
2729

2830
applicationStore.addEventListener('error', (errorResponse) => {
31+
console.log('error');
2932
applicationsInitialized.value = true;
3033
error.value = errorResponse;
3134
});
3235

36+
applicationStore.addEventListener('removed', () => {
37+
console.log('removed');
38+
applicationsInitialized.value = false;
39+
});
40+
3341
return { applications, applicationsInitialized, error, applicationStore };
3442
}

spring-boot-admin-server-ui/src/main/frontend/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ const app = createApp({
7474

7575
onBeforeMount(() => {
7676
applicationStore.start();
77-
})
77+
});
7878

7979
onBeforeUnmount(() => {
8080
applicationStore.stop();
81-
})
81+
});
8282

8383
return () => h(sbaShell, props);
8484
},
@@ -98,10 +98,10 @@ installables.forEach((view) => {
9898
try {
9999
view.configure
100100
? view.configure({
101-
vue,
102-
i18n: vue.$i18n,
103-
axios,
104-
})
101+
vue,
102+
i18n: vue.$i18n,
103+
axios,
104+
})
105105
: void 0;
106106
} catch (e) {
107107
console.error(`Error configuring view ${view}`, e);

0 commit comments

Comments
 (0)