1.0.5 • Published 2 years ago

signalr-event-emitter v1.0.5

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 years ago

signalr-event-emitter

npm

A utility function that allows for receiving method invocations from a SignalR hub in a type-safe way

Why?

Because the SignalR client library leaves a lot to be desired in terms of nice typescript support. The createSignalrEventEmitter function in this package allows for defining event names and parameters via TypeScript.

Example

// build hub connection
const hubConnection = new signalR.HubConnectionBuilder()
  .withUrl('/somehub')
  .build();


// define method names and the parameters expected
interface Methods {
  started: () => void;
  progress: (processedCount: number, totalCount: number) => void;
  finished: () => void;
}

// attach emitter
const emitter = createSignalrEventEmitter<Methods>(hubConnection);


emitter.on('progress', (processedCount, totalCount) => {

});
1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago