【发布时间】:2023-02-08 02:39:09
【问题描述】:
我有 3 个组件地图、字段和部分。地图是父组件。 Field & Section 是子组件。
Field 组件中有一个名为testField 的操作。在 test 函数中,首先我想在 Section 组件上触发一个事件 SaveSection 然后继续其他事情。
// In field component
public function testField(): void
{
// Save section
$this->emitTo('section', 'saveSection');
Log::debug('Testing.....');
}
// In section component
public function saveSection()
{
Log::debug('saveSection+++++');
$this->emitTo('map', 'storeSection', $this->section, $this->sectionIndex);
}
// In map component
public function storeSection(array $section, int $sectionIndex)
{
Log::debug('storeSection-----');
// Store to DB
....
}
但它在storeSection----- 之前打印Testing.....。有什么办法可以让我等到事件结束后再继续。
【问题讨论】:
-
您是否发出 livewire 事件并试图检测事件何时被处理?
-
@mrtorks 是的,类似的东西。我想在保存数据后进行测试。
标签: laravel-livewire