2.0.4 • Published 1 year ago

@types/sc-channel v2.0.4

Weekly downloads
3,013
License
MIT
Repository
github
Last release
1 year ago

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

// Type definitions for sc-channel 2.0
// Project: https://github.com/SocketCluster/sc-channel
// Definitions by: Daniel Rose <https://github.com/DanielRose>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Minimum TypeScript Version: 3.7

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.

1.2.5

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.4

1 year ago

2.0.1

3 years ago

1.2.2

3 years ago

1.2.1

5 years ago

2.0.0

5 years ago

1.2.0

6 years ago