Skip to content

1.9.0

Latest
Compare
Choose a tag to compare
@armiol armiol released this 22 May 11:09
b1e7317

This release updates the Dart client API and implementation to be compatible with Spine 1.9.0 release.

It includes the changes as follows:

Customization of communication with back-end

HttpTranslator is introduced to allow customization of HTTP request execution. In particular, it makes possible to define the HTTP headers of the requests sent to back-end, as well as translate the back-end responses.

Here is how to supply a custom HttpTranslator:

import 'package:spine_client/http_client.dart';

class CustomHttpTranslator extends HttpTranslator {

    // ... 

    @override
    Map<String, String> headers(Uri uri) => {'Custom-Header': 'foo-bar'};
}

// ...
var clients = Clients(backendUrl,
                      // ...
                      httpTranslator: CustomHttpTranslator(...));

If the translator is not customized, the behavior is the same as in previous Dart client releases:

  • application/x-protobuf content-type set for all requests,
  • HTTP request body is a Proto message transformed to bytes, and encoded with Base64,
  • HTTP responses are treated as JSON strings, and parsed accordingly.

Subscription to entity deletions and archivals

The recent changes in Spine web back-end made possible to receive the subscription updates whenever the matching entity is archived or deleted. Previously, this functionality was still supported by Dart client API, but in fact it was not functioning properly.

A word on streams in subscriptions

The subscription API is build around Dart streams. At the moment, only broadcast streams are supported by Dart client.
While it is possible to use Dart built-in mechanisms to perform the conversion of single-subscription streams into broadcast streams, it cannot be performed with proper performance and behavior generally. Therefore, any custom implementations of FirebaseClient should return broadcast streams, performing the conversion internally if needed.

Exposing more API

Some API which was previously inaccessible to end-users is now available. In particular:

  • json.dart — the conversion of Proto messages from JSON strings into objects;
  • known_types.dart — a registry of all Proto types known to the library; required in order to create Proto messages via parsing.

These files were moved from lib/src to lib folder.

Dart dependency updates

This release removes the dependency onto Firebase client implementation which is specific to web.

Also, this release specifies the dartdoc dependency as ^5.0.0 to support null safety.