From bde27a25575a77fe2ed639206baa60ea4254e1e5 Mon Sep 17 00:00:00 2001 From: Dmitry Borisenko Date: Sun, 15 Aug 2021 19:42:42 +0000 Subject: [PATCH] new type of data pushing --- src/App.svelte | 16 ++++++---------- src/Input.svelte | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/App.svelte b/src/App.svelte index f64ef10..03ce399 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -6,10 +6,10 @@ import Card from "./Card.svelte"; import Input from "./Input.svelte"; // - let text1 = ""; - let text2 = ""; - const handleChange1 = value => (text1 = value); - const handleChange2 = value => (text2 = value); + let incommingText = ""; + function handleMessage(event) { + incommingText = event.detail.text; + }
@@ -148,12 +148,8 @@ - -

{text1}

-
- - -

{text2}

+ +

{incommingText}

diff --git a/src/Input.svelte b/src/Input.svelte index a220bee..b09f55c 100644 --- a/src/Input.svelte +++ b/src/Input.svelte @@ -1,12 +1,12 @@ + export let title; + let text; + import { createEventDispatcher } from "svelte"; + const dispatch = createEventDispatcher(); + function sendInputText() { + dispatch("msg1", { text: text }); + } +
@@ -14,7 +14,7 @@
- +
- \ No newline at end of file +