Skip to main content

Hi, I’m an author of an figwire - lightweight typescript friendly library for seamless communication between plugin and UI layers.

https://www.npmjs.com/package/figwire

 

How does it work:

  1. For the work on the plugin side use imports from `figwire/plugin`, and for the work on the ui side use imports from `figwire/ui` 
  2. On the one side you define the methods that will be available on the other side:
    const pluginApi = defineApi({
    greet: (name: string) => `Hello ${name}!`
    });

     

  3. Export the type for these definitions:

    export type PluginAPIDefinition = typeof pluginApi;

     

  4. Provide the type for the client on the other side:
    const pluginApiClient = client<PluginAPIDefinition>();

     

  5. Use the methods using typescript suggestions:

    const greeting = await pluginApiClient.greet('Johnny Jeep');

 

And that’s it.

 

It’s an early release, therefore I am open to suggestions.

Please let me know what you think!

 

Be the first to reply!

Reply