API.md

June 8, 2018 ยท View on GitHub

Index

HubConnectionFactory

HubConnection

Hub Connection Factory

Methods

create

Allow you register one or more hub connections.

ParametersTypeDefaultRequiredDescription
connectionOptions...HubConnectionOptions[]-yesoptions

Return HubConnectionFactory

HubConnectionOptions

NameTypeDefaultRequiredDescription
keystring-yesFriendly name.
endpointUristring-yesHub endpoint uri which is mapped with signalr hub. eg: /userNotifications.
optionsConnectionOptions-noSignalR connection options.
defaultData() => Dictionary<string>-nokey value pair to be sent as query string to the server. This can be extended or overridden from connect or setData
protocolIHubProtocol-noSignalr connection protocol.

get

This will retrieve a hub connection by Key.

ParametersTypeDefaultRequiredDescription
THubTHub-yesResponse type.
keystring-yesUnique identifier.

Return HubConnection<THub>

remove

Removes a specific hub connection by Key.

ParametersTypeDefaultRequiredDescription
keystring-yesUnique identifier.

Return void

connectAll

Iterates on all available connections and connects.

ParametersTypeDefaultRequiredDescription
-----

Return void

disconnectAll

Iterates on all available connections and disconnects.

ParametersTypeDefaultRequiredDescription
-----

Return void

Hub Connection

Properties

connectionState$

Subscribes for connection state updates.

Return Observable<ConnectionState>

Methods

connect

Connect with the specific hub connection.

notes

  • The data function will be triggered on every reconnect. This will allow any data which is stale (example: auth token) will be refreshed.
ParametersTypeDefaultRequiredDescription
data() => Dictionary<string> --key value pair which will be sent as query string. This can will extend or override the defaultData

Return Observable<void>

setData

Send data with a specific connection as query string. When calling this method, it will automatically disconnects, sets data and depending the previous connection state it will either reconnect or not.

notes

  • If before calling this method the connection was disconnected, this will only set the data.
  • The data function will be triggered on every reconnect. This will allow any data which is stale (example: auth token) will be refreshed.
ParametersTypeDefaultRequiredDescription
data() => Dictionary<string> --key value pair which will be sent as query string. This can will extend or override the defaultData

Return void

on

Subscribe to particular topic.

ParametersTypeDefaultRequiredDescription
TResultTResult-yesTResult returned response.
topicNamestring-yesAny data that will be dispatched on this topic will be received.

Return Observable<TResult>

stream

Subscribe to particular stream on the server hub.

ParametersTypeDefaultRequiredDescription
TResultTResult-yesTResult returned response.
methodNamestring-yesMethodName which exists on the server hub.
...argsany[]-noAny parameters which will be send to the server hub when invoking the MethodName.

Return Observable<TResult>

send

Dispatch a message to communicates with the server hub.

note: This doesn't return any response. If you need any response from the server hub use invoke instead.

ParametersTypeDefaultRequiredDescription
methodNamestring-yesMethodName which exists on the server hub.
...argsany[]-noAny parameters which will be send to the server hub when invoking the MethodName.

Return Observable<void>

invoke

Dispatch a message to communicates with the server hub and the server hub will return a response.

note: If you do not need to wait for any response, use send instead.

ParametersTypeDefaultRequiredDescription
TResultTResult-yesTResult returned response.
methodNamestring-yesMethodName which exists on the server hub.
...argsany[]-noAny parameters which will be send to the server hub when invoking the MethodName.

Return Observable<TResult>

disconnect

Disconnect from a specific hub connection.

ParametersTypeDefaultRequiredDescription
-----

Return Observable<void>