Skip to content
This repository was archived by the owner on Oct 14, 2022. It is now read-only.

Support returned values from JS events #20

@nesk

Description

@nesk

This could be done with a Pipe class added to a JS function:

use Nesk\Rialto\Data\JsFunction;
use Nesk\Rialto\Data\Pipe;

// Create a new pipe to transfer values from JS to PHP
$pipe = new Pipe;

// Create a JS function with the pipe
$jsFunction = JsFunction::createWithBody("
    const value = { foo: 'bar' }
    customPipe.sendValue(value)
")->addPipe('customPipe', $pipe);

// Use the JS function with Rialto's implementation...

// Retrieve the transfered values through an iterator
foreach ($pipe as $value) {
    var_dump($value); // Outputs: array(1) { 'foo' => string(3) "bar" }
}

Each time the iterator of the Pipe class is called, the next value will be retrieved by communicating with the Node process. Once the value is retrieved, the Node process deletes it and will no longer be available.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions