AppMage

ReactiveData

This endpoint group provides methods for clients to retrieve the initial state of reactive data sets and to fetch specific data sets on demand. Reactive data sets are configured on the server to automatically push updates to connected clients when underlying data changes.

Endpoints

POST /api/rpc (Method: ReactiveDataRpc.getInitialState)

  • Description: Gets the initial state for a list of reactive data sets.

  • Request Body:

    {
      "method": "ReactiveDataRpc.getInitialState",
      "params": {
        "dataSetNames": [
          "dataSet1",
          "dataSet2"
        ]
      }
    }
  • Parameters:

    Name Type Required Description
    dataSetNames Array<String> Yes An array of names of the reactive data sets for which to retrieve the initial state.
  • Response:

    {
      "success": true,
      "data": {
        "dataSet1": [
          {
            "_id": "...",
            "field1": "value1"
          }
        ],
        "dataSet2": [
          {
            "_id": "...",
            "fieldA": "valueA"
          }
        ]
      }
    }

    The data field will contain an object where keys are the dataSetNames and values are arrays of objects representing the initial data for each set, filtered according to the server-side configuration of the reactive data set. This method delegates to ReactiveDataService.getInitialState.

  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "ReactiveDataRpc.getInitialState",
        "params": {
          "dataSetNames": ["myUsers", "myProducts"]
        }
      }'

POST /api/rpc (Method: ReactiveDataRpc.getDataSet)

  • Description: Gets a single reactive data set on demand, usually triggered by a client-side event.

  • Request Body:

    {
      "method": "ReactiveDataRpc.getDataSet",
      "params": {
        "dataSetName": "myDynamicDataSet",
        "filterContext": {
          "projectId": "abc-123"
        }
      }
    }
  • Parameters:

    Name Type Required Description
    dataSetName String Yes The name of the reactive data set to retrieve.
    filterContext Object No Dynamic filter values from the trigger event, e.g., { projectId: '...' }. This object will be merged with any server-side filters defined for the data set.
  • Response:

    {
      "success": true,
      "data": [
        {
          "_id": "...",
          "dynamicField": "dynamicValue"
        }
      ]
    }

    The data field will contain an array of objects representing the requested data set, filtered by the provided filterContext and any server-side configuration. This method delegates to ReactiveDataService.getDataSet.

  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "ReactiveDataRpc.getDataSet",
        "params": {
          "dataSetName": "projectTasks",
          "filterContext": {
            "projectId": "654321"
          }
        }
      }'