update method

Future<AsklessResponse> update({
  1. required String route,
  2. required dynamic body,
  3. Map<String, dynamic>? params,
  4. bool neverTimeout = false,
  5. bool persevere = false,
})

Performs a request attempt for a update route added on the server side

body The entire data or field(s) that will be updated.

route The path of the route.

params Additional data (optional).

neverTimeout Default: false (optional). If true: the request attempt will live as long as possible.

If false: if the request doesn't receive a response within the time limit, it will be canceled. The field requestTimeoutInMs defined on the server side will be the time limit.

persevere Default: false (optional). If persevere is true and this route was created in the server with addRouteFor.authenticatedUsers (requires authentication) but clearAuthentication() is called, then this route will wait for the authentication to come back. In case of false the route will be canceled right after clearAuthentication() is called (only if this route requires authentication). This is no-op in case this route doesn't require authentication (addRoute.forAllUsers).

Example

    AsklessClient.instance
        .update(
            route: 'allProducts',
            params: {
              'nameContains' : 'game'
            },
            body: {
              'discount' : 0.8
            }
        ).then((res) => print(res.success ? 'Success' : res.error!.code));

Implementation

Future<AsklessResponse> update({required String route, required dynamic body, Map<String, dynamic>? params, bool neverTimeout = false, bool persevere = false}) async {
  assert(body!=null);
  await getIt.get<ConnectionService>().waitForConnectionOrTimeout(timeout: neverTimeout ? null : Duration(milliseconds: getIt.get<ConnectionService>().connectionConfiguration.requestTimeoutInMs));

  return getIt.get<RequestsService>().runOperationInServer(
    data: UpdateCli(route: route, body: body, params: params),
    neverTimeout: neverTimeout,
    isPersevere: () => persevere,
  );
}