@cloudpss/message-stream
v0.5.42
Published
Message stream type definitions for cloudpss APIs. And plugin for `@cloudpss/http-client`, provides cloudpss message stream APIs.
Downloads
80
Readme
@cloudpss/message-stream
Message stream type definitions for cloudpss APIs. And plugin for @cloudpss/http-client
, provides cloudpss message stream APIs.
Example
import { HttpClient } from '@cloudpss/http-client';
import { MessageStreamPlugin } from '@cloudpss/message-stream/plugin';
import { interval } from 'rxjs';
import { map, take } from 'rxjs/operators';
const http = new HttpClient({
/* config */
}).use(MessageStreamPlugin());
const stream = await http.stream.create({ type: 'object', comment: 'test', durability: 0 });
await http.stream.write(
stream.token,
stream.type,
interval(100)
.pipe(take(10))
.pipe(map((i) => ({ i }))),
);
await http.stream.freeze(stream.token);