ParallelApi<O> class

An aggregated API that calls multiple APIs in parallel.

For example

Api templateApi = SingleApi<DataSet,DataSet>(
  name: "get user",
  serverName: "local server",
  method:HttpMethod.POST
  path:"/users",
  inputCreator: (context){
    DataSet ds = DataSet("Condition");
    ds.setHeaderSchema(
      RecordSchema([FieldSchema<String>("id")])
    );
    return ds;
  },
  outputCreator: (context){
    DataSet ds = DataSet("User");
    ds.setHeaderSchema(
      RecordSchema(
        [
          FieldSchema<String>("name"),
          FieldSchema<int>("age"),
          FieldSchema<String>("tel")
        ]
      )
    );
    return ds;
  }
);

Api api = ParallelApi<List<Object>>(
  name: "get users",
  apis: [templateApi, templateApi]
);

RequestContext context = RequestContext();
List<DataSet> requests = api.getInput(context).cast();
requests[0].getHeader()["id"] = "0000001";
requests[1].getHeader()["id"] = "0000002";

List<DataSet> responses = (await api.request(requests, context)).cast();

Record userRecord1 = responses[0].getHeader();
Record userRecord2 = responses[1].getHeader();
Inheritance
Annotations

Constructors

ParallelApi({required String name, required List<Api> apis, ApiInOutCreator<O>? outputCreator})

Properties

hashCode int
The hash code for this object.
no setterinherited
name → dynamic
A logical name of API.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

getInput(RequestContext context) List<Object>
Get the input DTO that is the source of the request to the server.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
request(List<Object>? input, RequestContext context) Future<O?>
Request to the server.
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited