Git Product home page Git Product logo

dart-threads-client's Introduction

dart-threads-client

Warning: The dart-threads-client library is temporarily deprecated as remote DB support not currently up-to-date with the Textile Hub and so will not work. If you are waiting for Dart support, please see here.

Made by Textile Chat on Slack GitHub license Dart CI Pub Threads version Build status

Textile's Dart client for interacting with remote Threads

Join us on our public Slack channel for news, discussions, and status updates. Check out our blog for the latest posts and announcements.

Table of Contents

Getting Started

In the pubspec.yaml of your project, add the following dependency:

dependencies:
  ...
  threads_client: "^0.x.x"

Connect to a Threads Daemon

You can use Textile's hosted daemons or run your own.

Use hosted Threads

Textile Threads.

Run your own daemon

You need to run a threads daemon available to the client.

git clone [email protected]:textileio/go-threads.git
cd go-threads
go run threadsd/main.go -debug

Usage

Read the Complete API Documentation.

Create a DB

import 'package:threads_client/threads_client.dart' as threads;

void main(List<String> args) async {
  final client = threads.Client();
  final dbId = 'bafk7ayo2xuuafgx6ubbcn2lro3s7oixgujdda6shv4';
  final creds = threads.Creds.fromStrings(dbId);
  await client.newDB(creds);
}

Run Threads using hosted Textile API

import 'package:textile/textile.dart' as textile;
import 'package:threads_client/threads_client.dart' as threads;

const APP_TOKEN = '<app token>';
const DEVICE_ID = '<uuid>';

void main(List<String> args) async {
  final config = textile.ThreadsConfig(APP_TOKEN, DEVICE_ID);
  final client = threads.Client(config: config);
  final dbId = 'bafk7ayo2xuuafgx6ubbcn2lro3s7oixgujdda6shv4';
  final creds = threads.Creds.fromStrings(dbId);
  await client.newDB(creds);
}

Further examples

You can find a good overview of Client methods in the test suite.

Threads Client Tests

Add custom metadata to requests

For example, add a custom auth token to the header of each request.

    final config = ThreadsConfig(
      host: '127.0.0.1',
      port: 6006,
      callOptionsMetaData: {
        'authorization': 'Bearer 3f2950d0-5522-4425-829f-75894e233442'
      }
    );
    // Create a new threads client
    client = Client(config);

Development

Install

Run the daemon, as above. Next, install and run the Dart threads_client:

git clone [email protected]:textileio/dart-threads-client.git
cd dart-threads-client
pub get

Run tests

dart test/threads_client_test.dart

Run example

dart example/helloworld.dart

Contributing

This project is a work in progress. As such, there's a few things you can do right now to help out:

  • Ask questions! We'll try to help. Be sure to drop a note (on the above issue) if there is anything you'd like to work on and we'll update the issue to let others know. Also get in touch on Slack.
  • Open issues, file issues, submit pull requests!
  • Perform code reviews. More eyes will help a) speed the project along b) ensure quality and c) reduce possible future bugs.
  • Take a look at the code. Contributions here that would be most helpful are top-level comments about how it should look based on your understanding. Again, the more eyes the better.
  • Add tests. There can never be enough tests.

Before you get started, be sure to read our contributors guide and our contributor covenant code of conduct.

Changelog

Changelog is published to Releases.

License

MIT

dart-threads-client's People

Contributors

andrewxhill avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.