Notoriously Pedantic Magistrate

    fable-import-signalr

    0.4.0 • Public • Published

    Fable bindings for SignalR

    npm version

    Usage

    Define hubs

     
        type [<AllowNullLiteral>] MyHub =
            abstract myUpdate: (float -> unit) with get, set
     
        type Hubs =
            inherit SignalR
            abstract myHub: HubClient<MyHub>

    Notes:

    • Hubs inherits from SignalR
    • HubClient is a binding that wraps members on the given type in a client variable

    Subscribe to hubs and start connection

    let connection = Globals.jQuery.connection :> Hubs
    connection.myHub.client.myUpdate <- (fun value -> printf "Got updated value: %f" value)
    connection.hub.start[ Transport [| "serverSentEvents"; "longPolling" |]] |> ignore
    

    Add Dependencies

    <script src="https://code.jquery.com/jquery-1.6.4.min.js"></script>
    <script src="http://ajax.aspnetcdn.com/ajax/signalr/jquery.signalr-2.2.1.min.js"></script>
    <script src="/signalr/hubs"></script>
    

    Install

    npm i fable-import-signalr

    DownloadsWeekly Downloads

    3

    Version

    0.4.0

    License

    MIT

    Last publish

    Collaborators

    • 2scomplement