mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
tiny-emitter package is used as "centralized event hub" between vis-network and vue3
This commit is contained in:
parent
a0940a0c85
commit
41f815bbb9
@ -80,10 +80,10 @@ export default {
|
||||
|
||||
},
|
||||
created() {
|
||||
eventHub.$on('add-switch', this.addSwitch)
|
||||
eventHub.on('add-relationship-link', this.addRelationshipLink)
|
||||
},
|
||||
unmounted() {
|
||||
eventHub.$off('add-switch', this.addSwitch)
|
||||
eventHub.off('add-relationship-link', this.addRelationshipLink)
|
||||
},
|
||||
mounted() {
|
||||
console.log('=== mounted: init graph')
|
||||
@ -124,8 +124,8 @@ export default {
|
||||
console.log('** click on node **')
|
||||
window.network.on('click', callback)
|
||||
},
|
||||
addSwitch(edgeData) {
|
||||
console.log('==> addSwitch <=======================', edgeData)
|
||||
addRelationshipLink(edgeData) {
|
||||
console.log('==> addRelationshipLink <=======================', edgeData)
|
||||
},
|
||||
}
|
||||
/*
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { visMessages } from './i18n'
|
||||
import {createApp} from "vue"
|
||||
import { TinyEmitter } from "tiny-emitter";
|
||||
|
||||
/**
|
||||
* Vis-network initial data/configuration script
|
||||
@ -8,10 +8,8 @@ import {createApp} from "vue"
|
||||
* cfr. https://github.com/almende/vis/issues/2524#issuecomment-307108271
|
||||
*/
|
||||
|
||||
console.log('@@@@@@@ eventHub App @@@@@@@@@@')
|
||||
window.eventHub = createApp()
|
||||
console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@')
|
||||
|
||||
console.log('@@@ init eventHub App @@@')
|
||||
window.eventHub = new TinyEmitter()
|
||||
|
||||
window.network = {}
|
||||
|
||||
@ -26,7 +24,7 @@ window.options = {
|
||||
showButton: true
|
||||
},
|
||||
*/
|
||||
physics:{
|
||||
physics: {
|
||||
enabled: true,
|
||||
barnesHut: {
|
||||
theta: 0.5,
|
||||
@ -104,7 +102,7 @@ window.options = {
|
||||
addEdge: function(edgeData, callback) {
|
||||
console.log('addEdge', edgeData)
|
||||
callback(edgeData)
|
||||
eventHub.$emit('add-switch', edgeData)
|
||||
eventHub.emit('add-relationship-link', edgeData)
|
||||
},
|
||||
editEdge: function(edgeData, callback) {
|
||||
console.log('editNode', edgeData)
|
||||
|
Loading…
x
Reference in New Issue
Block a user