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

Lean Clients #701

Open
maurerbot opened this issue Dec 17, 2022 · 0 comments
Open

Lean Clients #701

maurerbot opened this issue Dec 17, 2022 · 0 comments

Comments

@maurerbot
Copy link

Generator should support leaner clients by specifying transport class upfront

Describe the solution you'd like
Within components subset of client.ts to eliminate switch statements and import only the transport requested.

Describe alternatives you've considered
None

Additional context
Here is the switch statement and import to be removed

import { RequestManager, PostMessageWindowTransport, PostMessageIframeTransport, WebSocketTransport, HTTPTransport, HTTPTransportOptions, Transport, Client, JSONRPCError } from "@open-rpc/client-js";


switch (type) {
      case 'injected':
        this.transport = injected;
        break;
      case 'http':
      case 'https':
        this.transport = new HTTPTransport((protocol || type) + "://" + host + ":" + port + path );
        break;
      case 'websocket':
        this.transport = new WebSocketTransport((protocol || "ws://") + host + ":" + port + path);
        break;
      case 'postmessageiframe':
        this.transport = new PostMessageIframeTransport(protocol + "://" + host + ":" + port + path);
        break;
      case 'postmessagewindow':
        this.transport = new PostMessageWindowTransport(protocol + "://" + host + ":" + port + path);
        break;
      default:
        throw new Error("unsupported transport");
        break;
    }
    ```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant