Clients constructor
Clients(
- String baseUrl, {
- UserId? guestId = null,
- TenantId? tenantId = null,
- ZoneOffset? zoneOffset = null,
- ZoneId? zoneId = null,
- QueryMode queryMode = QueryMode.FIREBASE,
- FirebaseClient? firebase = null,
- Endpoints? endpoints = null,
- Duration subscriptionKeepUpPeriod = const Duration(minutes: 2),
- List typeRegistries = const [],
- HttpTranslator? httpTranslator = null,
Creates a new instance of Clients.
Parameters:
baseUrl— the base URL of the server which receives the requests from the clients;guestId— the defaultUserIdto use in the "guest" mode; the default isUserId(value = "guest");tenantId— the tenant ID; use this argument only in multitenant systems;zoneOffsetandzoneId— the time zone in which the created clients operate; by default, uses the system time zone;queryMode— the query processing mode which should be used by the created clients; see QueryMode for more info; the default value isFIREBASE;firebase— a FirebaseClient which precesses queries and subscriptions; ifqueryModeis QueryMode.DIRECT and subscriptions are not required, this argument can be skipped;endpoints— the custom endpoints of the backend; see Endpoints for the defaults;subscriptionKeepUpPeriod— the time between subscription keep-up requests; 2 minutes by default;onNetworkError— a callback handling network errors; should receive either error as the only argument or error and StackTrace; should return aFutureOr<Response>;typeRegistries— a list of known type registries; thedart_code_gentool generates thetypes.dartfiles for each module for main and test scopes. Atypes.dartfile contains information about the known Protobuf types of this module. See the class level doc for an example of how to access a type registry and pass it to this constructor;httpTranslator— a custom instance of HttpTranslator, which allows to configure how HTTP requests are sent, and how their responses are treated. By default, a new instance of HttpTranslator will be used.
Implementation
Clients(String baseUrl,
{UserId? guestId = null,
TenantId? tenantId = null,
ZoneOffset? zoneOffset = null,
ZoneId? zoneId = null,
QueryMode queryMode = QueryMode.FIREBASE,
FirebaseClient? firebase = null,
Endpoints? endpoints = null,
Duration subscriptionKeepUpPeriod = const Duration(minutes: 2),
List<dynamic> typeRegistries = const [],
HttpTranslator? httpTranslator = null}) :
_httpClient = _createHttpClient(baseUrl, httpTranslator),
_guestId = guestId ?? _DEFAULT_GUEST_ID,
_tenant = tenantId,
_zoneOffset = zoneOffset,
_zoneId = zoneId,
_endpoints = endpoints ?? Endpoints(),
_firebase = firebase
{
_checkNonNullOrDefault(_guestId, 'guestId');
_queryProcessor = _chooseProcessor(queryMode, _httpClient, firebase);
theKnownTypes.registerAll(typeRegistries);
Timer.periodic(subscriptionKeepUpPeriod,
(timer) => _refreshSubscriptions());
}