Create Variables to Temporarily Store Data Changes in a Buffer

When you work with variables based on component data providers such as Service Data Provider and Array Data Provider, you can temporarily store data changes in a buffer until they are ready to be committed to the data source. To do this, you use variables based on a Buffering Data Provider.

The Buffering Data Provider is a wrapper that provides buffering for an underlying data provider, so edits can be committed to the data source later on. The underlying data provider is responsible for data fetches, while the Buffering Data Provider takes care of merging any buffered edits with the underlying data. This is useful functionality for batch processing, especially in the context of editable tables. For example, when users edit multiple existing rows or create new rows in a table, all changes can be stored in a buffer until the user clicks a Save button, at which time a REST call posts the buffered changes to the backend service. The buffered changes are held in a variable based on the built-in Buffering Data Provider type.

Buffering Data Providers require data providers that provide the actual data. For example, when you create a table based on a quick start, a Service Data Provider type variable is created to hold the table's data. The Buffering Data Provider simply wraps this underlying data provider to provide additional functionality, such as buffering for CRUD operations, commit, and revert. So before you create a Buffering Data Provider variable, make sure the underlying data provider is available.

Here's how to create a Buffering Data Provider variable and map it to the underlying data provider:

  1. Click Variables to open the Variables editor for your scope.
  2. Click + Variable to open the New Variable dialog box.
  3. Give the variable a name (for example, employeeBDP) in the ID field and select Buffering Data Provider as the Type.
  4. Click Create to create your Buffering Data Provider variable. Here's an example of a newly created Buffering Data Provider variable:

  5. The Buffering Data Provider variable allows you to pass values to the constructor to initialize the newly created instance's properties. Here are the two Constructor Parameters it accepts:
    1. To map the Buffering Data Provider variable to your component's underlying data provider, in the newly created variable's Properties pane, click the dataProvider Constructor Parameter.
      In the Map Variables to Parameters dialog, map the original data provider on the Sources pane (for example, the employeeListSDP variable created when a table component is mapped to its data source) to the dataProvider parameter on the Target pane. Click Save.
    2. To pass any options from the underlying data provider, click options under Constructor Parameters, map the required variables, and click Save.
  6. Bind the Buffering Data Provider variable to your component. Variables based on the Buffering Data Provider type can be bound to tables, list views, or any component that accepts a data provider.
    1. Switch to the Page Designer and select (for example) your table component.
    2. In the table's Data tab, open the variable picker and select the instance of the Buffering Data Provider, instead of the original data provider. For example, you might replace $variables.employeeListSDP with $variables.employeeBDP.instance: