Skip to main content

index

Classes

abstract SubscriptionDatabase

Constructors

new SubscriptionDatabase()

new SubscriptionDatabase(): SubscriptionDatabase

Returns

SubscriptionDatabase

Methods

createSubscription()

createSubscription(info): Promise<void>

Parameters
ParameterType

info

SubscriptionInfo

Returns

Promise<void>

deleteSubscription()

deleteSubscription(id): Promise<void>

Parameters
ParameterType

id

string

Returns

Promise<void>

deleteSubscriptions()

deleteSubscriptions(connectionId): Promise<void>

Parameters
ParameterType

connectionId

string

Returns

Promise<void>

getSubscriptions()

getSubscriptions(topic): Promise<SubscriptionInfo[]>

Parameters
ParameterType

topic

string

Returns

Promise<SubscriptionInfo[]>


SubscriptionDatabaseD1

Implements

Constructors

new SubscriptionDatabaseD1()

new SubscriptionDatabaseD1(db): SubscriptionDatabaseD1

Parameters
ParameterType

db

D1Database

Returns

SubscriptionDatabaseD1

Properties

PropertyModifierTypeDefault value

table

protected

string

'Subscriptions'

Methods

createSubscription()

createSubscription(info): Promise<void>

Parameters
ParameterType

info

SubscriptionInfo

Returns

Promise<void>

Implementation of

SubscriptionDatabase.createSubscription

deleteSubscription()

deleteSubscription(id): Promise<void>

Parameters
ParameterType

id

string

Returns

Promise<void>

Implementation of

SubscriptionDatabase.deleteSubscription

deleteSubscriptions()

deleteSubscriptions(connectionId): Promise<void>

Parameters
ParameterType

connectionId

string

Returns

Promise<void>

Implementation of

SubscriptionDatabase.deleteSubscriptions

getSubscriptions()

getSubscriptions(topic): Promise<SubscriptionInfo[]>

Parameters
ParameterType

topic

string

Returns

Promise<SubscriptionInfo[]>

Implementation of

SubscriptionDatabase.getSubscriptions

Interfaces

SubscriptionInfo

Properties

PropertyType

connectionId

string

connectionPoolId

string

contextParams

unknown

id

string

subscription

SubscribePayload

topic

string


SubscriptionsContextLoader<Env, Context, ContextParams>

Type Parameters

Type Parameter

Env

Context

ContextParams

Properties

PropertyType

createContext

(params: ContextParams, env: Env, executionContext: ExecutionContext) => Context

getContextParams

(request: Request<unknown, CfProperties<unknown>>, env: Env) => ContextParams


SubscriptionsOptions<Env, Context, ContextParams>

Type Parameters

Type Parameter

Env

Context

ContextParams

Properties

PropertyType

getDatabase

(env: Env) => SubscriptionDatabase

getWSConnections

(env: Env) => DurableObjectNamespace<undefined>

schema

GraphQLSchema

context?

SubscriptionsContextLoader<Env, Context, ContextParams>

poolingType?

PoolingType

Type Aliases

PoolingType

PoolingType: "global" | "colo" | "continent" | "none"


Publish()<Map>

Publish<Map>: <C, P>(topic, payload) => Promise<void>

Type Parameters

Type Parameter

Map extends Record<string, any>

Type Parameters

Type Parameter

C extends keyof Map

P extends Map[C]

Parameters

ParameterType

topic

C

payload

P

Returns

Promise<void>


Subscribe()<Map>

Subscribe<Map>: <C, P>(topic) => AsyncIterator<P>

Type Parameters

Type Parameter

Map extends Record<string, any>

Type Parameters

Type Parameter

C extends keyof Map

P extends Map[C]

Parameters

ParameterType

topic

C

Returns

AsyncIterator<P>

Functions

createCloudflareSubscription()

createCloudflareSubscription<Env, Context, ContextParams, PubSubMap>(options): object

Type Parameters

Type ParameterDefault type

Env

Context

ContextParams

PubSubMap extends Record<string, any>

Record<string, any>

Parameters

ParameterType

options

SubscriptionsOptions<Env, Context, ContextParams>

Returns

object

NameType
createPublisher(env, execContext) => Publish<PubSubMap>
createSubscriber() => Subscribe<PubSubMap>
createWsConnectionsClass() => (state, env) => DurableObject
handleWS(request, env, execContext) => Promise<Response>