0.1.0Manages Elixir by setting up iframe, WASM module, and event listeners. Used to sent messages to Elixir processes.
(any)
(any)
Creates an iframe and sets up communication channels.
Returns after the Elixir app calls Popcorn.Wasm.ready/0,1.
(any)
import { Popcorn } from "@swmansion/popcorn";
const popcorn = await Popcorn.init({
onStdout: console.log,
onStderr: console.error,
debug: true,
});
Sends a message to an Elixir process and awaits for the response.
If Elixir doesn't respond in configured timeout, the returned promise will be rejected with "process timeout" error.
Unless passed via options, the name passed in Popcorn.Wasm.set_default_receiver/1 on the Elixir side is used.
Throws "Unspecified target process" if default process is not set and no process is specified.
(any)
(Object
= {})
| Name | Description |
|---|---|
$1.process any
|
|
$1.timeoutMs any
|
const result = await popcorn.call(
{ action: "get_user", id: 123 },
{ process: "user_server", timeoutMs: 5_000 },
);
console.log(result.data); // Deserialized Elixir response
console.log(result.durationMs); // Entire call duration
Sends a message to an Elixir process (default or from options) and returns immediately.
Unless passed via options, the name passed in Popcorn.Wasm.set_default_receiver/1 on the Elixir side is used.
Throws "Unspecified target process" if default process is not set and no process is specified.
(any)
(Object
= {})
| Name | Description |
|---|---|
$1.process any
|
Destroys an iframe and resets the instance.
Registers a log listener that will be called when output of the specified type is received.
(any)
(any)
Unregisters a previously registered log listener.
(any)
(any)
Registers a catch-all event handler. Returns an unsubscribe function.
(any)
Recoverable error returned in CallResult (never thrown)
Extends Error
(any)
(any)
Non-recoverable error indicating a bug or library misuse (always thrown)
Extends Error
(any)
(any)