Nag*_*ngh 5 javascript performance server-sent-events eventsource
我看到一个库允许使用Header
EventSource 自定义标头。
但是,当我看到网络选项卡时,Type
显示的fetch
不是 ,eventsource
而如果我使用本机,EventSource
它会生成类型为eventsource
。
fetch
和之间的性能有区别吗eventsource
?
使用 Polyfill
const eventSourceInitDict = {headers: {
'ClientId': '123123123',
'ClientSecret': 'lllasjdlkasjdlkasdlka'
}};
const objEventSource1 = new EventSourcePolyfill('https://*****.herokuapp.com/emit-custom-pe?userId=' + '{!$User.Id}', eventSourceInitDict);
objEventSource1.addEventListener('message', function (objEventSourceData) {
debugger;
});
Run Code Online (Sandbox Code Playgroud)
使用本机事件源
const objEventSource1 = new EventSource('https://****.herokuapp.com/emit-custom-pe?userId=' + '{!$User.Id}');
objEventSource1.addEventListener('message', function (objEventSourceData) {
debugger;
});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1625 次 |
最近记录: |