Hi ->to(OrderItemBlock::class); means that only that type of component will listen to the event. is the Y component of that type?
May 3, 2024
10
Level 1
Listen to events while redirect
Hello, I have X and Y component, in X component, I am dispatching event with data, but with redirect to another route, where another Y component is loading.
// Method to emit event with table name and navigate to the desired route
public function navigateToOrdering($tableName)
{
// Emit event to OrderItemBlock component with tableName
$this->dispatch('navigateToOrdering', $tableName)->to(OrderItemBlock::class);
// Navigate to the pos.ordering route without passing tableName in URL
return redirect()->route('pos.ordering');
}
in Y component I am listening as below,
#[On('navigateToOrdering')]
public function receiveTableName($tableName)
{
$this->tableName = $tableName;
dd($this->tableName);
// Handle the received tableName as needed in this component
}
But I could not get output of dd means tableName,
will this dispatch work in redirect? or any other way to move to new page with dispatch?
Please or to participate in this conversation.