absinthe_socket 0.0.3 copy "absinthe_socket: ^0.0.3" to clipboard
absinthe_socket: ^0.0.3 copied to clipboard

A GraphQL subscription client for Absinthe sockets.

absinthe_socket #

A dart client for GraphQL subscriptions via Absinthe sockets

Getting Started #

Use the package:

# pubspec.yaml
# ...
  absinthe_socket: ^0.0.3
# ...

Create a socket, connect it, add a subscription:

    _socket = AbsintheSocket("ws://10.0.2.2:4000/socket/websocket");
    Observer _categoryObserver = Observer(
        onAbort: _onAbort,
        onCancel: _onCancel,
        onError: _onError,
        onResult: _onResult,
        onStart: _onStart);

    Notifier notifier = _socket.send(GqlRequest(
        operation:
            "subscription CategoryAdded { categoryAdded { id, title } }"));
    notifier.observe(_categoryObserver);
    // I also track notifiers to cancel them when my flutter widget is disposed of
    _notifiers.add(notifier);
    // Then when the widget is disposed, I cancel the notifiers:
    _notifiers.forEach((Notifier notifier) => _socket.cancel(notifier))
    // And you can disconnect the socket:
    _socket.disconnect();

This is a shameless bad rip-off of part of the API of @absinthe/socket.

3
likes
15
pub points
10%
popularity

Publisher

unverified uploader

A GraphQL subscription client for Absinthe sockets.

Repository
View/report issues

License

MIT (LICENSE)

Dependencies

phoenix_wings

More

Packages that depend on absinthe_socket