Skip to content
Learn Netverks

Lesson

Step 10/36 28% through track

emits-up

Emits up

Last reviewed Jun 1, 2026 Content v20260601
Track mode
client_vue
Means
In-browser Vue TS
Reading
~1 min
Level
intermediate

This lesson

This lesson teaches Emits up: the concepts, APIs, and habits you need before advancing in Vue.

Child-to-parent communication uses emits with typed payloads in TypeScript projects.

You will apply Emits up in contexts like: Greenfield SPAs, dashboards, design systems, and full-stack apps that pair Vue with PHP or Node APIs.

Write TypeScript, click Run—Vue 3 loads from CDN with the template compiler, mountApp shows UI in #app, and printOutput feeds the terminal.

When you can explain the previous lesson's ideas without copying starter code.

While props flow down, events flow up. Children signal parents with emit—the Vue counterpart to passing callback props in React.

Declaring and using emits

emits: ['increment'],
setup(props, { emit }) {
  function onClick() {
    emit('increment');
  }
  return { onClick };
}

Declare event names in emits for documentation and validation. In templates you can also use $emit('increment'), but calling emit inside setup keeps logic testable.

Payloads

Pass data with the second argument: emit('select', item.id). The parent listens with @select="onSelect" and receives the payload as the first handler argument.

Important interview questions and answers

  1. Q: emit vs mutating props?
    A: Always prefer explicit events (or v-model) over prop mutation—one-way data flow stays predictable.
  2. Q: How is emit like React?
    A: Similar to onSave={() => ...} callback props, but Vue names events explicitly in emits.

Self-check

  1. Where do you declare allowed event names?
  2. How does the parent listen for increment?

Challenge

Counter with emit

  1. Click the child button and confirm the parent count increases.
  2. Add a second emit decrement and wire a minus button.

Done when: parent count updates from child button clicks via emits.

Tip: Name emits after user actions (save, close) or use update:modelValue for v-model-compatible components.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs in your browser in a sandboxed frame. Backend runners appear when this track’s profile allows them.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • Event you emitted?
  • Payload typing plan?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump