I’m planning to search an entire Figma file for layers that use a given style and list them out in my plugin UI. Since this operation is potentially time-consuming (for files that has thousands or even millions of layers), I would like to update my plugin ui in batches of data while the search is happening concurrently
eg Suppose I want to find all layers that have a style of id s:145y5687… and list them down in my plugin UI. Let’s say that there are over 10,000 layers in a user’s figma file so figma.root.findAll(…) will take over an hour to completely synchronously. I want to wait to collect first 50 results from figma.root.findAll(…), process them while figma.root.findAll(…) is running concurrently, then wait until another 50 new results are received.
So here’s my question:
- Is it possible to run figma.root.findAll(…) asynchronously?
- if 1 is possible, how do I process the returned results in batches?
I’m new to asynchronous functions and promises so any help is appreciated!