- Getting Started
- The Basics
- Concepts
- SuperNative
-
EDGE Components
- Introduction
- Activity Indicator
- Badge
- Bottom Navigation
- Bottom Sheet
- Button
- Button Group
- Canvas
- Carousel
- Checkbox
- Chip
- Column
- Divider
- Gesture Area
- Icon
- Icons
- Image
- Layout & Styling
- List
- Menus
- Modal
- Pressable
- Progress Bar
- Radio Group
- Row
- Scroll View
- Select
- Shapes
- Side Navigation
- Slider
- Spacer
- Stack
- Tab Row
- Text
- Text Input
- Toggle
- Top Bar
- Virtual List
- Web View
- Plugins
- Testing
- Architecture
You're viewing pre-release documentation — version 4.x is in beta
Features, APIs and behaviour may change before the stable release. View the stable version (3.x)
Events
Dispatching Events from Native Code#
Many native operations are asynchronous — ML inference, sensor readings, background tasks. Your native code needs a way to send results back to PHP when they're ready. That's where events come in.
Events are dispatched from native code and received by your Livewire components.
Declaring Events#
Add your event classes to the manifest:
{ "events": [ "Vendor\\MyPlugin\\Events\\ProcessingComplete", "Vendor\\MyPlugin\\Events\\ProcessingError" ]}
Creating Event Classes#
Events are simple PHP classes:
namespace Vendor\MyPlugin\Events; use Illuminate\Foundation\Events\Dispatchable;use Illuminate\Queue\SerializesModels; class ProcessingComplete{ use Dispatchable, SerializesModels; public function __construct( public string $result, public ?string $id = null ) {}}
Swift Event Dispatching#
Dispatch events using LaravelBridge.shared.send:
// Build your payloadlet payload: [String: Any] = [ "result": processedData, "id": requestId] // Dispatch to PHPLaravelBridge.shared.send?( "Vendor\\MyPlugin\\Events\\ProcessingComplete", payload)
This runs synchronously on the main thread, so wrap in DispatchQueue.main.async if needed.
Kotlin Event Dispatching#
Dispatch events using NativeActionCoordinator.dispatchEvent:
import android.os.Handlerimport android.os.Looper // Build your payloadval payload = JSONObject().apply { put("result", processedData) put("id", requestId)} // Must dispatch on main threadHandler(Looper.getMainLooper()).post { NativeActionCoordinator.dispatchEvent( activity, "Vendor\\MyPlugin\\Events\\ProcessingComplete", payload.toString() )}
Official Plugins & Dev Kit#
Skip the complexity — browse ready-made plugins or get the Dev Kit to build your own. Visit the NativePHP Plugin Marketplace →
in no time