Replies: 2 comments 12 replies
-
Edit: Events don't need a subscription. The following is valid for listeners only.You need to subscribe (As implemented here): // App.vue
<script setup lang="ts">
import { onMounted, onBeforeUnmount } from 'vue'
import List from './components/DnDList.vue'
import { store } from '@dflex/dnd'
// Effect for layoutState
onMounted(() => {
const unsubscribeLayout = store.listeners.subscribe((e) => {
console.info('new layout state', e)
}, 'layoutState')
onBeforeUnmount(() => {
unsubscribeLayout()
})
})
// Effect for mutation
onMounted(() => {
const unsubscribeMutation = store.listeners.subscribe((e) => {
console.info('new mutation state', e)
}, 'mutation')
onBeforeUnmount(() => {
unsubscribeMutation()
})
})
</script> |
Beta Was this translation helpful? Give feedback.
-
Yes, but I still don't understand why do we need to subscribe to layout/mutation explicitly just to be able to receive these regular DFlex events (the ones that happen during drag&drop operation). I am trying to understand the architectural decision of that approach. It seems I am missing something here which I would like to understand.
How can I subscribe to those encompassed events? I don't understand :) Sorry, I've read the reply once more and I still got questions :) |
Beta Was this translation helpful? Give feedback.
-
Here is the code sandbox for the use-case: https://codesandbox.io/p/sandbox/holy-hill-fy6sy2
Open the console (the Debugger icon in the top right) and observe no console logs during drag operation.
None of the registered events are dispatched. What am I doing wrong?
Note: I also tried attaching them to
document
but still no success.Beta Was this translation helpful? Give feedback.
All reactions