• Robert Knight's avatar
    Remove `onConnect` method from Bridge · c72257a9
    Robert Knight authored
    Simplify the Bridge class by removing the `onConnect` API and replacing
    current calls with alternative approaches.
    
    The `onConnect` method was a way to register a callback that would be invoked
    after a test RPC call over a newly-connected channel succeeded.
    
    The purpose of this method was not that clear however and its existence
    suggested that it is necessary to wait for the callback to be invoked before
    making RPC requests on the new channel. This is not the case, as the underlying
    transport buffers messages until the receiver is ready to consume them. Therefore
    RPC requests can be made as soon as `createChannel` returns.
    
    The current uses of `onConnect` were replaced as follows:
    
     1. The host frame used it to be notified when the sidebar application has
        loaded. This has been replaced with an explicit `ready` RPC call.
    
     2. The sidebar waited for this callback before querying metadata for a
        newly-connected guest. It now sends a metadata query to the guest
        immediately when it receives the guest port from the host frame. This saves
        an unnecessary round-trip between the host and guest. In future we can
        optimize metadata querying more by having the guest _push_ metadata to
        the sidebar rather than waiting for the sidebar to query it.
    c72257a9
Name
Last commit
Last update
..
rpc-bridge-test.js Loading commit data...