0.8.0 • Published 6 years ago

brayns v0.8.0

Weekly downloads
2
License
LGPL-3.0+
Repository
github
Last release
6 years ago

Brayns JavaScript/TypeScript Client

A JavaScript/TypeScript interface for interacting with the Brayns rendering service.

Table of Contents

Installation


You can install this package from NPM:

npm add rxjs rockets-client brayns

Or with Yarn:

yarn add rxjs rockets-client brayns

NOTE: TypeScript type definitions are bundled with the package.

Usage


Create a client and connect:

import {Client} from 'brayns';
import {take} from 'rxjs/operators';

const brayns = new Client('myhost');
await brayns.ready.pipe(take(1))
    .toPromise();

Listen to server notifications:

import {Client, PROGRESS} from 'brayns';

const brayns = new Client('myhost');

brayns.observe(PROGRESS)
    .subscribe(progress => {
        console.log(progress);
    });

Send notifications:

import {CANCEL, Client} from 'brayns';

const brayns = new Client('myhost');
await brayns.ready.pipe(take(1))
    .toPromise();

brayns.notify(CANCEL, {
    id: 1 // some request id
});

Make a request:

import {Client, GET_STATISTICS} from 'brayns';

const brayns = new Client('myhost');
await brayns.ready.pipe(take(1))
    .toPromise();

const statistics = await brayns.request(GET_STATISTICS);
console.log(statistics);

Upload a model:

import {Client} from 'brayns';

const brayns = new Client('myhost');
await brayns.ready.pipe(take(1))
    .toPromise();

// Usually we get the file from user input
const file = new File([]);

await brayns.upload({file});