How can I change the “Could not reconnect to the server” text in Blazor?

前端 未结 3 1276
灰色年华
灰色年华 2020-12-31 07:45

I am using the Blazor server-side.

When the Blazor App disconnect to the remote server, it will shows this:

I want to change the text (\'Could not

3条回答
  •  没有蜡笔的小新
    2020-12-31 08:42

    For the javascript side of things Blazor exposes a tiny API via the window.Blazor object.

    One part of this API is the defaultReconnectionHandler which allows you to customize the reconnection experience including setting different options for the number of retrys etc.

    However, it is also possible to just swap out the logic for displaying the ReconnectionDisplay

    A simple implemenation looks like this and enables you to to get controll over the process:

    function createOwnDisplay() {
        return {
            show: () => { alert("put code that shows a toast , ui, or whaterver here"); },
            hide: () => { console.log('foo'); },
            failed: () => { console.log('foo'); },
            rejected: () => { console.log('foo'); }
        };
    }
    
    Blazor.defaultReconnectionHandler._reconnectionDisplay = createOwnDisplay();
    

提交回复
热议问题