BETA We're building something new — all help is welcome! Contribute →

#[Isolate]

Exclude a component from request pooling for independent AJAX requests.

Basic Usage

By default, LiVue batches multiple simultaneous AJAX requests into a single HTTP call. Use #[Isolate] to opt out and send requests independently.

use LiVue\Attributes\Isolate;

#[Isolate]
class SlowDashboard extends Component
{
    public array $stats = [];

    public function loadStats()
    {
        // Slow external API call
        $this->stats = ExternalApi::fetchStats();
    }
}

Request Pooling Explained

Without isolation, LiVue's request pooling works like this:

Without #[Isolate]

Requests are batched together:

// User clicks button on Component A and B
→ Single HTTP request with both updates
// Both wait for the slowest to complete

With #[Isolate]

Requests are independent:

// User clicks button on Component A and B
→ Component A: separate request
→ Component B: separate request

When to Use

Slow API calls

Components that fetch from slow external services shouldn't block others.

Heavy database queries

Analytics dashboards or reports with complex queries.

Critical UI components

Components that need to respond quickly regardless of other operations.

Unpredictable response times

Components whose response time varies significantly.

Visual Example

Consider a page with a fast counter and a slow dashboard:

// Fast counter - stays in pool
class Counter extends Component
{
    public int $count = 0;

    public function increment() { $this->count++; }
}

// Slow dashboard - isolated
#[Isolate]
class Dashboard extends Component
{
    public function refresh()
    {
        // 3-second API call won't block Counter
        sleep(3);
    }
}

Without #[Isolate], clicking both buttons would make the counter wait 3 seconds. With isolation, the counter responds instantly.

How It Works

  1. 1
    Flag set at render

    The isolate: true flag is added to the snapshot memo and as data-livue-isolate on the wrapper.

  2. 2
    Client detects isolation

    When a request is made, the runtime checks for the isolate flag in the payload.

  3. 3
    Separate fetch sent

    Instead of being queued in the pool, an immediate separate HTTP request is dispatched.

Considerations

More HTTP Requests

Isolated components send separate requests, which increases total HTTP traffic. Use this attribute only when the performance benefit outweighs the cost of additional requests.