From ecf9c812f1ac41a83654e319ddff9921ffaadc12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Kie=C3=9Fling?= Date: Mon, 6 May 2024 12:45:28 +0200 Subject: [PATCH] Fixed event data passing example --- src/LiveComponent/doc/index.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/LiveComponent/doc/index.rst b/src/LiveComponent/doc/index.rst index 0d6c04957d1..d1c7ecf1ae2 100644 --- a/src/LiveComponent/doc/index.rst +++ b/src/LiveComponent/doc/index.rst @@ -2728,7 +2728,7 @@ You can also pass extra (scalar) data to the listeners:: // ... $this->emit('productAdded', [ - 'product' => $product->getId(), + 'productId' => $product->getId(), ]); } @@ -2736,10 +2736,10 @@ In your listeners, you can access this by adding a matching argument name with ``#[LiveArg]`` in front:: #[LiveListener('productAdded')] - public function incrementProductCount(#[LiveArg] int $product) + public function incrementProductCount(#[LiveArg] int $productId) { $this->productCount++; - $this->lastProduct = $data['product']; + $this->lastProductId = $productId; } And because event listeners are also actions, you can type-hint an argument