Cristiano Magro
2024-12-30 501f0d04371ebcdd9d9401d9e5b911b75f22ddef
08 - component communication/cmp-communication-08-a-potential-problem-starting-setup/src/App.vue
@@ -4,7 +4,7 @@
      :topic-title="activeTopic && activeTopic.title"
      :text="activeTopic && activeTopic.fullText"
    ></active-element>
    <knowledge-base :topics="topics" @select-topic="activateTopic"></knowledge-base>
    <knowledge-base ></knowledge-base>
  </div>
</template>
@@ -32,11 +32,28 @@
      activeTopic: null,
    };
  },
  provide(){
    return {
      topics: this.topics,
      selectTopic: this.activateTopic,
    }
  },
  methods: {
    activateTopic(topicId) {
      this.activeTopic = this.topics.find((topic) => topic.id === topicId);
    },
  },
  mounted(){
    setTimeout(() => {
      this.topics.push({
          id: 'events',
          title: 'Events',
          description: 'Vieni all\'evento',
          fullText:
            'Gli eventi ti permettono di triggherare il codice on demand',
        });
    }, 3000);
  }
};
</script>