Skip to content

gavinmcfarland/figma-msgr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

Msgr

Messenger is a simple message handler for Figma.

Note

This hasn't been packaged yet and is mainly a learning experience for me.

Create an instance of Msgr

In both the UI and main code you'll need to create an instance of Msgr.

const msgr = new Msgr();

Defining handlers

Define your event handlers.

const msgr = new Msgr({ handlers });

const handlers = {
  greet(value: any) {
    console.log(value);
  },
};

Emitting a message

Calling emit invokes the event handler for the matching event name in either UI or main context.

msgr.emit("greet", "Hello world!");

Awaiting a response

After emitting a message you can await a response from the other context.

let res = await msgr.emit("greet");

About

A simple message handler for Figma

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published