Dynamically configure anything
Dynamically build your Space configuration as it’s created.
The DevXP engineering team hosts office hours every Thursday at 11 a.m. Pacific Time where we answer your questions live and help you get up and running with Flatfile. Join us!
Flatfile can support the simplest of workflows to the most nuanced & complex with Dynamic Spaces.
Use cases
The use cases for dynamic configuration are endless, here are just a few ideas:
- Perhaps the user who is creating the Space informs how you want that Space to look for them
- Or maybe someone’s location defines a different type of currency in your Sheet configuration
- Or say you need data from an external API in a precise moment in time to determine how you want your Workbook to look
Continue reading to learn how to configure a Space from scratch, and update it as things change.
Configuring a new Space
From the dashboard
When the “Create New Space” button is clicked on the platform, it triggers a job event
within the space domain
that initiates a configure operation
. This operation is analogous to performing a POST request to the endpoint /api/v1/spaces with the parameter autoconfigure
set to true.
- Filter on the
domain
(space) and theoperation
(configure). - Listen for a
job:ready
event. - Build your Space, at minimum including one Workbook.
- Complete the job.
- Optionally, listen for new events that are spawned from within your
space:configure
job.
Usage
In the following example, we build a Workbook and our getting started guide. You can also follow along in the flatfile-docs-kitchen-sink Github sandbox.
Be sure to complete the job when it’s complete. This tells the platform that you’re finished and ready to display the Space to the end user.
See full code example in our flatfile-docs-kitchen-sink Github repo
From an embedded button
When embedding Flatfile in your application, two things can happen:
- A new Space is created every time the Flatfile platform is called to open
- Or an existing Space can be passed in.
Listeners can be set up either server-side (use this Guide) and/or client-side within the embedded wrapper SDK.
Learn more about this use case.
Automatically
New Spaces can be created automatically by setting up headless flows.
Learn more about this use case.
Updating a Space in place
As things are changing in a Space, sometimes you may want to adjust the configuration of your Space. You can do this by listening for events that take place, and performing work as a result.
Continue reading for a few common examples.
After an action is fired
When a button is clicked in the user interface, this creates a job. You are already listening for this job to respond and do the work of that Action; however, you may also want to adjust some of your configuration at the same time, too.
Usage
In the following example, we lock down access to the original Sheet and update our getting started guide to reflect the change.
See full code example in our flatfile-docs-kitchen-sink Github repo
After data changes
As the Sheet is being updated with data, perhaps you want to change the configuration. In the following example, we listed for a commit created to do just that.
Usage
See full code example in our flatfile-docs-kitchen-sink Github repo
Example Project
Find the dynamic-configurations example in the Flatfile GitHub repository.