Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push parsing support #70

Open
halaxa opened this issue Jan 5, 2022 · 0 comments
Open

Push parsing support #70

halaxa opened this issue Jan 5, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@halaxa
Copy link
Owner

halaxa commented Jan 5, 2022

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?

@halaxa halaxa added the enhancement New feature or request label Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Inbox
Development

No branches or pull requests

1 participant