Skip to content

Push parsing support #70

@halaxa

Description

@halaxa

Support to incrementally feed the parser via an explicit method call where the pull approach of foreach cannot be used. Useful for example for curl's CURLOPT_WRITEFUNCTION or when receiving json chunks in an event loop.

Proposed usage (implicit):

$items = new PushItems(['pointer' => '/results']);

$callback = function ($jsonChunk) use ($items) {
    $items->push($jsonChunk);
    foreach($items as $item) {
        // process currently available items
    }
}

or more explicit (similar to current API):

$queue = new QueueChunks();
$items = Items::fromQueue($queue, ['pointer' => '/results']);

$callback = function ($jsonChunk) use ($items, $queue) {
    $queue->push($jsonChunk);
    foreach($items as $item) {
        // process currently available items
    }
}

Any other proposal?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status

    Inbox

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions