Skip to content

Latest commit

 

History

History
37 lines (25 loc) · 1.02 KB

CHANGELOG.md

File metadata and controls

37 lines (25 loc) · 1.02 KB

msw-signalr

2.0.0

Major Changes

  • 4ba6b11: # Migrate to MSW 2.x

    Mock Service Worker 2 features stream responses, which makes mocking a SignalR hub significantly easier. The mock request handler implementation now uses Server Sent Events instead of Long-Polling.

    API changes

    signalRHandlers was renamed to signalRHub to better reflect the changed role:

    - import { signalRHandlers } from "msw-signalr";
    + import { signalRHub } from "msw-signalr"

    signalRHub returns an object with handlers, connections, and broadcast function, which takes the role of the formally global send.

    - export const server = setupServer(...signalRhandlers("/hub"));
    + export const hub = signalRHub("/hub");
    + export const worker = setupWorker(...hub.handlers);
    - send("foo", "bar")
    + hub.broadcast("foo", "bar")

    The connections property can now be used to send messages to individual clients:

    hub.connections.get("some-id").send("foo", "bar");