bosbase 0.25.1 copy "bosbase: ^0.25.1" to clipboard
bosbase: ^0.25.1 copied to clipboard

Multi-platform Dart SDK for Bosbase, an open source realtime backend in 1 file.

example/example.dart

// ignore_for_file: unnecessary_lambdas

import "dart:async";

import "package:bosbase/bosbase.dart";

void main() {
  final pb = Bosbase("http://127.0.0.1:8090");

  // fetch a paginated list with "example" records
  pb.collection("example").getList(page: 1, perPage: 10).then((result) {
    // success...
    print("Result: $result");
  }).catchError((dynamic error) {
    // error...
    print("Error: $error");
  });

  // listen to realtime connect/reconnect events
  pb.realtime.subscribe("PB_CONNECT", (e) {
    print("Connected: $e");
  });

  // subscribe to realtime changes in the "example" collection
  pb.collection("example").subscribe("*", (e) {
    print(e.action); // create, update, delete
    print(e.record); // the changed record
  });

  // unsubsribe from all "example" realtime subscriptions after 10 seconds
  Timer(const Duration(seconds: 10), () {
    pb.realtime.unsubscribe(); // unsubscribe from all realtime events
  });
}
0
likes
155
points
31
downloads

Publisher

unverified uploader

Weekly Downloads

Multi-platform Dart SDK for Bosbase, an open source realtime backend in 1 file.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

http, json_annotation, web_socket_channel

More

Packages that depend on bosbase