Methods
import { useEvent } from "effector-vue/ssr";
Deprecated

Since effector-vue 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

  1. unit (Event or Effect): Event or effect which will be bound to current scope

Returns

(Function): Function to pass to event handlers. Will trigger a given unit in current scope

Examples

Basic

model.ts
import { createStore, createEvent } from "effector";
export const incremented = createEvent();
export const $count = createStore(0);
$count.on(incremented, (x) => x + 1);
Counter.vue
<script setup lang="ts">
import { useStore } from "effector-vue/composition";
import { useEvent } from "effector-vue/ssr";
import { $count, incremented } from "./model";
const counter = useStore($count);
const onIncrement = useEvent(incremented);
</script>
<template>
<button @click="onIncrement">{{ counter }}</button>
</template>
Contributors