Cristiano Magro
2024-12-30 7ae0e73aec282b48f263c8bf9f6d6e8475793fbd
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 @select-topic="activateTopic"></knowledge-base>
  </div>
</template>
@@ -32,11 +32,27 @@
      activeTopic: null,
    };
  },
  provide(){
    return {
      topics: this.topics
    }
  },
  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>