How to use the @shopify/rpc.createEndpoint function in @shopify/rpc

To help you get started, we’ve selected a few @shopify/rpc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Shopify / quilt / packages / web-worker / src / create / worker.ts View on Github external
function createWorker({
    createMessenger = createWorkerMessenger,
  }: CreateWorkerOptions = {}): Endpoint['call'] {
    if (scriptUrl) {
      const endpoint = createEndpoint(createMessenger(scriptUrl));
      const {call: caller} = endpoint;

      workerEndpointCache.set(caller, endpoint);

      return caller as any;
    }

    // The babel plugin that comes with this package actually turns the argument
    // into a string (the public path of the worker script). If it’s a function,
    // it’s because we’re in an environment where we didn’t transform it into a
    // worker. In that case, we can use the fact that we will get access to the
    // real module and pretend to be a worker that way.
    if (typeof script === 'function') {
      return new Proxy(
        {},
        {

@shopify/rpc

Utilities for `postMessage`-based remote procedure calls

MIT
Latest version published 3 years ago

Package Health Score

60 / 100
Full package analysis