import { useEvent } from "effector-vue/ssr";
Deprecated
Since effector 23.0.0 useEvent
is deprecated. Use useUnit
instead.
Bind event to current fork instance to use in dom event handlers. Used only with ssr, in application without forks useEvent
will do nothing
Methods
useEvent(unit)
Arguments
Returns
(Function
): Function to pass to event handlers. Will trigger a given unit in current scope
Examples
Basic
import { createStore, createEvent } from "effector";
import { useEvent } from "effector-vue/ssr";
const incremented = createEvent();
const $count = createStore(0);
$count.on(incremented, (x) => x + 1);
export default {
setup() {
const counter = useStore($count);
const onIncrement = useEvent(incremented);
return {
onIncrement,
counter,
};
},
};