@types/sc-channel
TypeScript icon, indicating that this package has built-in type declarations

2.0.4 • Public • Published

Installation

npm install --save @types/sc-channel

Summary

This package contains type definitions for sc-channel (https://github.com/SocketCluster/sc-channel).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/sc-channel.

index.d.ts

import AsyncIterableStream = require("async-iterable-stream");
import StreamDemux = require("stream-demux");
import DemuxedConsumableStream = require("stream-demux/demuxed-consumable-stream");

declare class SCChannel<T> extends AsyncIterableStream<T> {
    readonly PENDING: "pending";
    readonly SUBSCRIBED: "subscribed";
    readonly UNSUBSCRIBED: "unsubscribed";

    name: string;
    client: SCChannel.Client;

    state: SCChannel.ChannelState;
    options: object;

    constructor(name: string, client: SCChannel.Client, eventDemux: StreamDemux<T>, dataStream: AsyncIterableStream<T>);

    createAsyncIterator(timeout?: number): AsyncIterableStream.AsyncIterator<T>;

    listener(eventName: string): DemuxedConsumableStream<T>;
    closeListener(eventName: string): void;
    closeAllListeners(): void;

    close(): void;

    subscribe(options?: any): void;
    unsubscribe(): void;

    isSubscribed(includePending?: boolean): boolean;

    publish(data: any): any;
}

export = SCChannel;

declare namespace SCChannel {
    interface Client {
        closeChannel(channelName: string): void;

        getChannelState(channelName: string): ChannelState;
        getChannelOptions(channelName: string): object;

        subscribe(channelName: string): SCChannel<any>;
        unsubscribe(channelName: string): void;
        isSubscribed(channelName: string, includePending?: boolean): boolean;

        publish(channelName: string, data: any): any;
    }

    type ChannelState = "pending" | "subscribed" | "unsubscribed";
}

Additional Details

Credits

These definitions were written by Daniel Rose.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/sc-channel

Weekly Downloads

503

Version

2.0.4

License

MIT

Unpacked Size

5.87 kB

Total Files

5

Last publish

Collaborators

  • types