{"id":54563,"date":"2025-08-13T07:50:31","date_gmt":"2025-08-12T23:50:31","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/54563.html"},"modified":"2025-08-13T07:50:31","modified_gmt":"2025-08-12T23:50:31","slug":"%e5%89%8d%e7%ab%af%e5%ae%9e%e6%97%b6%e6%95%b0%e6%8d%ae%e6%b5%81%e5%a4%84%e7%90%86%e4%b8%8e%e6%b5%81%e5%bc%8f%e6%b8%b2%e6%9f%93%e6%80%a7%e8%83%bd%e4%bc%98%e5%8c%96%ef%bc%9a%e5%9f%ba%e4%ba%8eevent-strea","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/54563.html","title":{"rendered":"\u524d\u7aef\u5b9e\u65f6\u6570\u636e\u6d41\u5904\u7406\u4e0e\u6d41\u5f0f\u6e32\u67d3\u6027\u80fd\u4f18\u5316\uff1a\u57fa\u4e8eEvent Stream\u4e0e\u670d\u52a1\u5668\u63a8\u9001\u7684\u9ad8\u6548\u5b9e\u73b0\u65b9\u6848"},"content":{"rendered":"<h5>&#x1f493; \u535a\u5ba2\u4e3b\u9875&#xff1a;\u7455\u75b5\u7684CSDN\u4e3b\u9875 <\/h5>\n<h5>&#x1f4dd; Gitee\u4e3b\u9875&#xff1a;\u7455\u75b5\u7684gitee\u4e3b\u9875<\/h5>\n<h5>\u23e9 \u6587\u7ae0\u4e13\u680f&#xff1a;\u300a\u70ed\u70b9\u8d44\u8baf\u300b<\/h5>\n<h2>\u524d\u7aef\u5b9e\u65f6\u6570\u636e\u6d41\u5904\u7406\u4e0e\u6d41\u5f0f\u6e32\u67d3\u6027\u80fd\u4f18\u5316&#xff1a;\u57fa\u4e8eEvent Stream\u4e0e\u670d\u52a1\u5668\u63a8\u9001\u7684\u9ad8\u6548\u5b9e\u73b0\u65b9\u6848<\/h2>\n<h4>\u76ee\u5f55<\/h4>\n<ul>\n<li>\u524d\u7aef\u5b9e\u65f6\u6570\u636e\u6d41\u5904\u7406\u4e0e\u6d41\u5f0f\u6e32\u67d3\u6027\u80fd\u4f18\u5316&#xff1a;\u57fa\u4e8eEvent Stream\u4e0e\u670d\u52a1\u5668\u63a8\u9001\u7684\u9ad8\u6548\u5b9e\u73b0\u65b9\u6848 <\/li>\n<li>\n<ul>\n<li>\u4e00\u3001\u5f15\u8a00 <\/li>\n<li>\u4e8c\u3001\u6838\u5fc3\u6982\u5ff5\u4e0e\u6280\u672f\u9009\u578b <\/li>\n<li>\n<ul>\n<li>1. Event Stream \u4e0e\u670d\u52a1\u5668\u63a8\u9001 <\/li>\n<li>\n<ul>\n<li>\u793a\u4f8b&#xff1a;SSE \u670d\u52a1\u7aef\u4ee3\u7801&#xff08;Node.js&#xff09; <\/li>\n<\/ul>\n<\/li>\n<li>2. \u6d41\u5f0f\u6e32\u67d3&#xff08;Streaming SSR&#xff09; <\/li>\n<li>\n<ul>\n<li>\u793a\u4f8b&#xff1a;React 18 \u6d41\u5f0f\u6e32\u67d3\u4ee3\u7801 <\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\u4e09\u3001\u5b9e\u65f6\u6570\u636e\u6d41\u5904\u7406\u4e0e\u6d41\u5f0f\u6e32\u67d3\u7684\u6574\u5408\u65b9\u6848 <\/li>\n<li>\n<ul>\n<li>1. \u6280\u672f\u67b6\u6784\u8bbe\u8ba1 <\/li>\n<li>2. \u5173\u952e\u5b9e\u73b0\u6b65\u9aa4 <\/li>\n<li>\n<ul>\n<li>&#xff08;1&#xff09;SSE \u5ba2\u6237\u7aef\u76d1\u542c <\/li>\n<li>&#xff08;2&#xff09;\u52a8\u6001\u6570\u636e\u6d41\u5904\u7406&#xff08;RxJS \u793a\u4f8b&#xff09; <\/li>\n<li>&#xff08;3&#xff09;React 18 \u6d41\u5f0f\u6e32\u67d3\u6574\u5408 <\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\u56db\u3001\u6027\u80fd\u4f18\u5316\u7b56\u7565 <\/li>\n<li>\n<ul>\n<li>1. \u5206\u9875\u4e0e\u865a\u62df\u6eda\u52a8 <\/li>\n<li>2. \u670d\u52a1\u7aef\u6d41\u5f0f\u6e32\u67d3\u4f18\u5316 <\/li>\n<li>\n<ul>\n<li>\u793a\u4f8b&#xff1a;Next.js \u6d41\u5f0f\u6e32\u67d3\u914d\u7f6e <\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\u4e94\u3001\u603b\u7ed3\u4e0e\u5c55\u671b <\/li>\n<li>\u516d\u3001\u53c2\u8003\u8d44\u6599 <\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>\u4e00\u3001\u5f15\u8a00<\/h3>\n<p>\u968f\u7740Web\u5e94\u7528\u590d\u6742\u5ea6\u7684\u63d0\u5347&#xff0c;\u5b9e\u65f6\u6570\u636e\u6d41\u5904\u7406\u4e0e\u9ad8\u6548\u6e32\u67d3\u6210\u4e3a\u524d\u7aef\u6027\u80fd\u4f18\u5316\u7684\u6838\u5fc3\u6311\u6218\u3002\u4f20\u7edfSSR&#xff08;\u670d\u52a1\u7aef\u6e32\u67d3&#xff09;\u548cCSR&#xff08;\u5ba2\u6237\u7aef\u6e32\u67d3&#xff09;\u6a21\u5f0f\u5728\u5904\u7406\u5927\u89c4\u6a21\u6570\u636e\u65f6&#xff0c;\u5e38\u9762\u4e34\u9996\u5c4f\u52a0\u8f7d\u5ef6\u8fdf\u3001\u8d44\u6e90\u963b\u585e\u3001\u5185\u5b58\u5360\u7528\u8fc7\u9ad8\u7b49\u95ee\u9898\u3002\u672c\u6587\u5c06\u6df1\u5165\u63a2\u8ba8\u5982\u4f55\u7ed3\u5408 Event Stream&#xff08;\u4e8b\u4ef6\u6d41&#xff09;\u4e0e \u670d\u52a1\u5668\u63a8\u9001\u6280\u672f&#xff08;\u5982SSE&#xff09;&#xff0c;\u901a\u8fc7\u6d41\u5f0f\u6e32\u67d3&#xff08;Streaming SSR&#xff09;\u548c\u52a8\u6001\u6570\u636e\u6d41\u5904\u7406&#xff0c;\u5b9e\u73b0\u9ad8\u6027\u80fd\u7684\u5b9e\u65f6\u4ea4\u4e92\u4f53\u9a8c\u3002 <\/p>\n<hr \/>\n<h3>\u4e8c\u3001\u6838\u5fc3\u6982\u5ff5\u4e0e\u6280\u672f\u9009\u578b<\/h3>\n<h4>1. Event Stream \u4e0e\u670d\u52a1\u5668\u63a8\u9001<\/h4>\n<p>Event Stream \u662f\u4e00\u79cd\u57fa\u4e8eHTTP\u7684\u5355\u5411\u901a\u4fe1\u534f\u8bae&#xff0c;\u5141\u8bb8\u670d\u52a1\u5668\u4e3b\u52a8\u5411\u5ba2\u6237\u7aef\u63a8\u9001\u6570\u636e\u6d41\u3002\u5176\u6838\u5fc3\u7279\u6027\u5305\u62ec&#xff1a; <\/p>\n<ul>\n<li>\u4f4e\u5ef6\u8fdf&#xff1a;\u670d\u52a1\u5668\u53ef\u5373\u65f6\u54cd\u5e94\u6570\u636e\u53d8\u5316&#xff0c;\u65e0\u9700\u5ba2\u6237\u7aef\u8f6e\u8be2\u3002 <\/li>\n<li>\u81ea\u52a8\u91cd\u8fde&#xff1a;\u6d4f\u89c8\u5668\u5185\u7f6e\u65ad\u7ebf\u91cd\u8fde\u673a\u5236&#xff0c;\u4fdd\u969c\u8fde\u63a5\u7a33\u5b9a\u6027\u3002 <\/li>\n<li>\u8f7b\u91cf\u534f\u8bae&#xff1a;\u57fa\u4e8e text\/event-stream \u683c\u5f0f&#xff0c;\u6613\u4e8e\u5b9e\u73b0\u4e0e\u96c6\u6210\u3002 <\/li>\n<\/ul>\n<p>\u9002\u7528\u573a\u666f&#xff1a; <\/p>\n<ul>\n<li>\u5b9e\u65f6\u884c\u60c5\u66f4\u65b0&#xff08;\u5982\u80a1\u7968\u3001\u671f\u8d27&#xff09;\u3002 <\/li>\n<li>\u804a\u5929\u5ba4\u6d88\u606f\u63a8\u9001\u3002 <\/li>\n<li>\u7269\u8054\u7f51\u8bbe\u5907\u72b6\u6001\u76d1\u63a7\u3002 <\/li>\n<\/ul>\n<h5>\u793a\u4f8b&#xff1a;SSE \u670d\u52a1\u7aef\u4ee3\u7801&#xff08;Node.js&#xff09;<\/h5>\n<p>const http &#061; require(&#039;http&#039;);<\/p>\n<p>http.createServer((req, res) &#061;&gt; {<br \/>\n  if (req.url &#061;&#061;&#061; &#039;\/sse&#039;) {<br \/>\n    res.writeHead(200, {<br \/>\n      &#039;Content-Type&#039;: &#039;text\/event-stream&#039;,<br \/>\n      &#039;Cache-Control&#039;: &#039;no-cache&#039;,<br \/>\n      &#039;Connection&#039;: &#039;keep-alive&#039;<br \/>\n    });<\/p>\n<p>    \/\/ \u6a21\u62df\u5b9a\u65f6\u63a8\u9001\u6570\u636e<br \/>\n    setInterval(() &#061;&gt; {<br \/>\n      const data &#061; JSON.stringify({ time: new Date().toISOString() });<br \/>\n      res.write(&#096;data: ${data}\\\\n\\\\n&#096;);<br \/>\n    }, 1000);<br \/>\n  }<br \/>\n}).listen(3000, () &#061;&gt; {<br \/>\n  console.log(&#039;Server running on port 3000&#039;);<br \/>\n});<\/p>\n<h4>2. \u6d41\u5f0f\u6e32\u67d3&#xff08;Streaming SSR&#xff09;<\/h4>\n<p>React 18 \u5f15\u5165\u7684 \u6d41\u5f0f\u6e32\u67d3 \u901a\u8fc7 renderToPipeableStream \u548c Suspense \u7ec4\u4ef6&#xff0c;\u5c06\u9875\u9762\u62c6\u5206\u4e3a\u591a\u4e2a\u72ec\u7acb\u533a\u5757&#xff0c;\u5b9e\u73b0\u8fb9\u6e32\u67d3\u8fb9\u8f93\u51fa\u7684\u673a\u5236\u3002 <\/p>\n<p>\u4f18\u52bf&#xff1a; <\/p>\n<ul>\n<li>\u9996\u5c4f\u52a0\u901f&#xff1a;\u4f18\u5148\u6e32\u67d3\u6838\u5fc3\u5185\u5bb9&#xff0c;\u51cf\u5c11\u7528\u6237\u7b49\u5f85\u65f6\u95f4\u3002 <\/li>\n<li>\u8d44\u6e90\u667a\u80fd\u52a0\u8f7d&#xff1a;\u7ed3\u5408 lazy \u5b9e\u73b0\u4ee3\u7801\u5206\u5272&#xff0c;\u975e\u5173\u952e\u8d44\u6e90\u5ef6\u8fdf\u52a0\u8f7d\u3002 <\/li>\n<li>TTFB \u4f18\u5316&#xff1a;\u670d\u52a1\u5668\u54cd\u5e94\u66f4\u5feb&#xff0c;\u663e\u8457\u63d0\u5347\u9996\u4e2a\u5b57\u8282\u5230\u8fbe\u65f6\u95f4\u3002 <\/li>\n<\/ul>\n<h5>\u793a\u4f8b&#xff1a;React 18 \u6d41\u5f0f\u6e32\u67d3\u4ee3\u7801<\/h5>\n<p>import { lazy, Suspense } from &#039;react&#039;;<\/p>\n<p>const HeavyComponent &#061; lazy(() &#061;&gt; import(&#039;.\/HeavyComponent&#039;));<\/p>\n<p>function App() {<br \/>\n  return (<br \/>\n    &lt;div&gt;<br \/>\n      &lt;Suspense fallback&#061;{&lt;div&gt;Loading Header&#8230;&lt;\/div&gt;}&gt;<br \/>\n        &lt;Header \/&gt;<br \/>\n      &lt;\/Suspense&gt;<br \/>\n      &lt;Suspense fallback&#061;{&lt;div&gt;Loading Content&#8230;&lt;\/div&gt;}&gt;<br \/>\n        &lt;HeavyComponent \/&gt;<br \/>\n      &lt;\/Suspense&gt;<br \/>\n    &lt;\/div&gt;<br \/>\n  );<br \/>\n}<\/p>\n<hr \/>\n<h3>\u4e09\u3001\u5b9e\u65f6\u6570\u636e\u6d41\u5904\u7406\u4e0e\u6d41\u5f0f\u6e32\u67d3\u7684\u6574\u5408\u65b9\u6848<\/h3>\n<h4>1. \u6280\u672f\u67b6\u6784\u8bbe\u8ba1<\/h4>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812235027-689bd343a0cdf.png\" alt=\"\u5b9e\u65f6\u6570\u636e\u6d41\u5904\u7406\u4e0e\u6d41\u5f0f\u6e32\u67d3\u67b6\u6784\u56fe\" \/> <\/p>\n<li>\u6570\u636e\u6e90&#xff1a;\u901a\u8fc7 SSE \u6216 WebSocket \u63a5\u6536\u670d\u52a1\u5668\u63a8\u9001\u7684\u5b9e\u65f6\u6570\u636e\u3002 <\/li>\n<li>\u6570\u636e\u5904\u7406\u5c42&#xff1a;\u4f7f\u7528 RxJS \u6216 KSQL \u5bf9\u6570\u636e\u6d41\u8fdb\u884c\u53bb\u91cd\u3001\u8fc7\u6ee4\u3001\u805a\u5408\u7b49\u64cd\u4f5c\u3002 <\/li>\n<li>\u524d\u7aef\u6e32\u67d3\u5c42&#xff1a;\u7ed3\u5408 React 18 \u7684 Suspense \u548c useEffect&#xff0c;\u5b9e\u73b0\u52a8\u6001\u66f4\u65b0\u4e0e\u6d41\u5f0f\u6e32\u67d3\u3002 <\/li>\n<h4>2. \u5173\u952e\u5b9e\u73b0\u6b65\u9aa4<\/h4>\n<h5>&#xff08;1&#xff09;SSE \u5ba2\u6237\u7aef\u76d1\u542c<\/h5>\n<p>const eventSource &#061; new EventSource(&#039;\/sse&#039;);<\/p>\n<p>eventSource.onmessage &#061; (event) &#061;&gt; {<br \/>\n  const data &#061; JSON.parse(event.data);<br \/>\n  updateUI(data); \/\/ \u66f4\u65b0\u524d\u7aef\u72b6\u6001<br \/>\n};<\/p>\n<p>eventSource.onerror &#061; (err) &#061;&gt; {<br \/>\n  console.error(&#039;SSE Error:&#039;, err);<br \/>\n};<\/p>\n<h5>&#xff08;2&#xff09;\u52a8\u6001\u6570\u636e\u6d41\u5904\u7406&#xff08;RxJS \u793a\u4f8b&#xff09;<\/h5>\n<p>import { fromEvent } from &#039;rxjs&#039;;<br \/>\nimport { filter, debounceTime, distinctUntilChanged } from &#039;rxjs\/operators&#039;;<\/p>\n<p>\/\/ \u76d1\u542c SSE \u6570\u636e\u6d41<br \/>\nconst sse$ &#061; fromEvent(eventSource, &#039;message&#039;).pipe(<br \/>\n  map(event &#061;&gt; JSON.parse(event.data)),<br \/>\n  filter(data &#061;&gt; data.type &#061;&#061;&#061; &#039;stock_price&#039;), \/\/ \u8fc7\u6ee4\u7279\u5b9a\u7c7b\u578b\u6570\u636e<br \/>\n  debounceTime(200), \/\/ \u9632\u6296\u53bb\u91cd<br \/>\n  distinctUntilChanged((prev, curr) &#061;&gt; prev.value &#061;&#061;&#061; curr.value)<br \/>\n);<\/p>\n<p>sse$.subscribe(data &#061;&gt; {<br \/>\n  \/\/ \u66f4\u65b0 UI \u6216\u89e6\u53d1\u91cd\u65b0\u6e32\u67d3<br \/>\n});<\/p>\n<h5>&#xff08;3&#xff09;React 18 \u6d41\u5f0f\u6e32\u67d3\u6574\u5408<\/h5>\n<p>import { Suspense, useEffect, useState } from &#039;react&#039;;<\/p>\n<p>function RealTimeData() {<br \/>\n  const [data, setData] &#061; useState(null);<\/p>\n<p>  useEffect(() &#061;&gt; {<br \/>\n    const eventSource &#061; new EventSource(&#039;\/sse&#039;);<br \/>\n    eventSource.onmessage &#061; (event) &#061;&gt; {<br \/>\n      setData(JSON.parse(event.data));<br \/>\n    };<br \/>\n  }, []);<\/p>\n<p>  return &lt;div&gt;{data ? &lt;DisplayData data&#061;{data} \/&gt; : &#039;Loading&#8230;&#039;}&lt;\/div&gt;;<br \/>\n}<\/p>\n<p>function DisplayData({ data }) {<br \/>\n  \/\/ \u6e32\u67d3\u5b9e\u65f6\u6570\u636e<br \/>\n  return &lt;pre&gt;{JSON.stringify(data, null, 2)}&lt;\/pre&gt;;<br \/>\n}<\/p>\n<hr \/>\n<h3>\u56db\u3001\u6027\u80fd\u4f18\u5316\u7b56\u7565<\/h3>\n<h4>1. \u5206\u9875\u4e0e\u865a\u62df\u6eda\u52a8<\/h4>\n<p>\u5bf9\u4e8e\u5927\u89c4\u6a21\u6570\u636e\u5217\u8868&#xff0c;\u91c7\u7528 \u865a\u62df\u6eda\u52a8&#xff08;Virtual Scrolling&#xff09;\u6280\u672f&#xff0c;\u4ec5\u6e32\u67d3\u53ef\u89c6\u533a\u57df\u5185\u7684\u6570\u636e\u9879\u3002 <\/p>\n<p>import { useState, useEffect } from &#039;react&#039;;<\/p>\n<p>function VirtualList({ items }) {<br \/>\n  const [visibleItems, setVisibleItems] &#061; useState([]);<\/p>\n<p>  useEffect(() &#061;&gt; {<br \/>\n    const handleScroll &#061; (e) &#061;&gt; {<br \/>\n      const scrollTop &#061; e.target.scrollTop;<br \/>\n      const startIndex &#061; Math.floor(scrollTop \/ 50); \/\/ \u6bcf\u9879\u9ad8\u5ea6 50px<br \/>\n      const endIndex &#061; startIndex &#043; 20; \/\/ \u663e\u793a 20 \u9879<br \/>\n      setVisibleItems(items.slice(startIndex, endIndex));<br \/>\n    };<\/p>\n<p>    const container &#061; document.getElementById(&#039;scroll-container&#039;);<br \/>\n    container.addEventListener(&#039;scroll&#039;, handleScroll);<br \/>\n    return () &#061;&gt; container.removeEventListener(&#039;scroll&#039;, handleScroll);<br \/>\n  }, [items]);<\/p>\n<p>  return (<br \/>\n    &lt;div id&#061;&#034;scroll-container&#034; style&#061;{{ height: &#039;500px&#039;, overflow: &#039;auto&#039; }}&gt;<br \/>\n      {visibleItems.map((item, index) &#061;&gt; (<br \/>\n        &lt;div key&#061;{index} style&#061;{{ height: &#039;50px&#039; }}&gt;<br \/>\n          {item}<br \/>\n        &lt;\/div&gt;<br \/>\n      ))}<br \/>\n    &lt;\/div&gt;<br \/>\n  );<br \/>\n}<\/p>\n<h4>2. \u670d\u52a1\u7aef\u6d41\u5f0f\u6e32\u67d3\u4f18\u5316<\/h4>\n<ul>\n<li>\u6309\u9700\u52a0\u8f7d&#xff1a;\u901a\u8fc7 renderToPipeableStream \u7684 onAllReady \u56de\u8c03\u4f18\u5148\u8f93\u51fa\u9996\u5c4f\u5185\u5bb9\u3002 <\/li>\n<li>\u7f13\u5b58\u7b56\u7565&#xff1a;\u5bf9\u9759\u6001\u7ec4\u4ef6&#xff08;\u5982\u9875\u811a\u3001\u5bfc\u822a\u680f&#xff09;\u542f\u7528\u670d\u52a1\u7aef\u7f13\u5b58&#xff0c;\u51cf\u5c11\u91cd\u590d\u6e32\u67d3\u5f00\u9500\u3002 <\/li>\n<\/ul>\n<h5>\u793a\u4f8b&#xff1a;Next.js \u6d41\u5f0f\u6e32\u67d3\u914d\u7f6e<\/h5>\n<p>import { renderToPipeableStream } from &#039;react-dom\/server&#039;;<\/p>\n<p>function App() {<br \/>\n  return (<br \/>\n    &lt;div&gt;<br \/>\n      &lt;Header \/&gt; {\/* \u9759\u6001\u7ec4\u4ef6&#xff0c;\u542f\u7528\u7f13\u5b58 *\/}<br \/>\n      &lt;Suspense fallback&#061;{&lt;div&gt;Loading&#8230;&lt;\/div&gt;}&gt;<br \/>\n        &lt;DynamicContent \/&gt; {\/* \u52a8\u6001\u5185\u5bb9\u6d41\u5f0f\u52a0\u8f7d *\/}<br \/>\n      &lt;\/Suspense&gt;<br \/>\n    &lt;\/div&gt;<br \/>\n  );<br \/>\n}<\/p>\n<p>const pipeable &#061; renderToPipeableStream(&lt;App \/&gt;, {<br \/>\n  onAllReady() {<br \/>\n    pipeable.pipe(res);<br \/>\n  }<br \/>\n});<\/p>\n<hr \/>\n<h3>\u4e94\u3001\u603b\u7ed3\u4e0e\u5c55\u671b<\/h3>\n<p>\u901a\u8fc7\u6574\u5408 Event Stream \u4e0e \u6d41\u5f0f\u6e32\u67d3 \u6280\u672f&#xff0c;\u524d\u7aef\u5e94\u7528\u80fd\u591f\u5728\u5b9e\u65f6\u6570\u636e\u5904\u7406\u548c\u6e32\u67d3\u6027\u80fd\u4e0a\u5b9e\u73b0\u8d28\u7684\u98de\u8dc3\u3002\u672a\u6765&#xff0c;\u968f\u7740 WebAssembly \u548c\u8fb9\u7f18\u8ba1\u7b97\u7684\u666e\u53ca&#xff0c;\u5b9e\u65f6\u6570\u636e\u6d41\u7684\u5904\u7406\u6548\u7387\u5c06\u8fdb\u4e00\u6b65\u63d0\u5347&#xff0c;\u800c AI \u9a71\u52a8\u7684\u52a8\u6001\u6e32\u67d3\u4f18\u5316&#xff08;\u5982\u9884\u6d4b\u6027\u52a0\u8f7d&#xff09;\u4e5f\u5c06\u6210\u4e3a\u65b0\u7684\u7814\u7a76\u65b9\u5411\u3002 <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812235028-689bd3443a3d2.png\" alt=\"\u6027\u80fd\u5bf9\u6bd4\u56fe&#xff1a;\u6d41\u5f0f\u6e32\u67d3 vs \u4f20\u7edf\u6e32\u67d3\" \/> <\/p>\n<hr \/>\n<h3>\u516d\u3001\u53c2\u8003\u8d44\u6599<\/h3>\n<li> <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812235028-689bd344da0c1.png\" alt=\"React 18 \u6d41\u5f0f\u6e32\u67d3\u5b98\u65b9\u6587\u6863\" \/> <\/li>\n<li> <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812235029-689bd3457b82a.png\" alt=\"SSE&#xff08;Server-Sent Events&#xff09;\u6280\u672f\u8be6\u89e3\" \/> <\/li>\n<li> <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812235030-689bd34621e30.png\" alt=\"RxJS \u6570\u636e\u6d41\u5904\u7406\u5b9e\u8df5\" \/><\/li>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb837\u6b21\uff0c\u70b9\u8d5e29\u6b21\uff0c\u6536\u85cf30\u6b21\u3002\u901a\u8fc7\u6574\u5408\u4e0e\u6d41\u5f0f\u6e32\u67d3\u6280\u672f\uff0c\u524d\u7aef\u5e94\u7528\u80fd\u591f\u5728\u5b9e\u65f6\u6570\u636e\u5904\u7406\u548c\u6e32\u67d3\u6027\u80fd\u4e0a\u5b9e\u73b0\u8d28\u7684\u98de\u8dc3\u3002\u672a\u6765\uff0c\u968f\u7740 WebAssembly \u548c\u8fb9\u7f18\u8ba1\u7b97\u7684\u666e\u53ca\uff0c\u5b9e\u65f6\u6570\u636e\u6d41\u7684\u5904\u7406\u6548\u7387\u5c06\u8fdb\u4e00\u6b65\u63d0\u5347\uff0c\u800c AI \u9a71\u52a8\u7684\u52a8\u6001\u6e32\u67d3\u4f18\u5316\uff08\u5982\u9884\u6d4b\u6027\u52a0\u8f7d\uff09\u4e5f\u5c06\u6210\u4e3a\u65b0\u7684\u7814\u7a76\u65b9\u5411\u3002_event-stream\u6d41\u683c\u5f0f\u5904\u7406<\/p>\n","protected":false},"author":2,"featured_media":54558,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[87,56,43,4901,44],"topic":[],"class_list":["post-54563","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-87","tag-56","tag-43","tag-4901","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u524d\u7aef\u5b9e\u65f6\u6570\u636e\u6d41\u5904\u7406\u4e0e\u6d41\u5f0f\u6e32\u67d3\u6027\u80fd\u4f18\u5316\uff1a\u57fa\u4e8eEvent Stream\u4e0e\u670d\u52a1\u5668\u63a8\u9001\u7684\u9ad8\u6548\u5b9e\u73b0\u65b9\u6848 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/54563.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u524d\u7aef\u5b9e\u65f6\u6570\u636e\u6d41\u5904\u7406\u4e0e\u6d41\u5f0f\u6e32\u67d3\u6027\u80fd\u4f18\u5316\uff1a\u57fa\u4e8eEvent Stream\u4e0e\u670d\u52a1\u5668\u63a8\u9001\u7684\u9ad8\u6548\u5b9e\u73b0\u65b9\u6848 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb837\u6b21\uff0c\u70b9\u8d5e29\u6b21\uff0c\u6536\u85cf30\u6b21\u3002\u901a\u8fc7\u6574\u5408\u4e0e\u6d41\u5f0f\u6e32\u67d3\u6280\u672f\uff0c\u524d\u7aef\u5e94\u7528\u80fd\u591f\u5728\u5b9e\u65f6\u6570\u636e\u5904\u7406\u548c\u6e32\u67d3\u6027\u80fd\u4e0a\u5b9e\u73b0\u8d28\u7684\u98de\u8dc3\u3002\u672a\u6765\uff0c\u968f\u7740 WebAssembly \u548c\u8fb9\u7f18\u8ba1\u7b97\u7684\u666e\u53ca\uff0c\u5b9e\u65f6\u6570\u636e\u6d41\u7684\u5904\u7406\u6548\u7387\u5c06\u8fdb\u4e00\u6b65\u63d0\u5347\uff0c\u800c AI \u9a71\u52a8\u7684\u52a8\u6001\u6e32\u67d3\u4f18\u5316\uff08\u5982\u9884\u6d4b\u6027\u52a0\u8f7d\uff09\u4e5f\u5c06\u6210\u4e3a\u65b0\u7684\u7814\u7a76\u65b9\u5411\u3002_event-stream\u6d41\u683c\u5f0f\u5904\u7406\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/54563.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-12T23:50:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812235027-689bd343a0cdf.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/54563.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/54563.html\",\"name\":\"\u524d\u7aef\u5b9e\u65f6\u6570\u636e\u6d41\u5904\u7406\u4e0e\u6d41\u5f0f\u6e32\u67d3\u6027\u80fd\u4f18\u5316\uff1a\u57fa\u4e8eEvent Stream\u4e0e\u670d\u52a1\u5668\u63a8\u9001\u7684\u9ad8\u6548\u5b9e\u73b0\u65b9\u6848 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-12T23:50:31+00:00\",\"dateModified\":\"2025-08-12T23:50:31+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/54563.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/54563.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/54563.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u524d\u7aef\u5b9e\u65f6\u6570\u636e\u6d41\u5904\u7406\u4e0e\u6d41\u5f0f\u6e32\u67d3\u6027\u80fd\u4f18\u5316\uff1a\u57fa\u4e8eEvent Stream\u4e0e\u670d\u52a1\u5668\u63a8\u9001\u7684\u9ad8\u6548\u5b9e\u73b0\u65b9\u6848\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u524d\u7aef\u5b9e\u65f6\u6570\u636e\u6d41\u5904\u7406\u4e0e\u6d41\u5f0f\u6e32\u67d3\u6027\u80fd\u4f18\u5316\uff1a\u57fa\u4e8eEvent Stream\u4e0e\u670d\u52a1\u5668\u63a8\u9001\u7684\u9ad8\u6548\u5b9e\u73b0\u65b9\u6848 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/54563.html","og_locale":"zh_CN","og_type":"article","og_title":"\u524d\u7aef\u5b9e\u65f6\u6570\u636e\u6d41\u5904\u7406\u4e0e\u6d41\u5f0f\u6e32\u67d3\u6027\u80fd\u4f18\u5316\uff1a\u57fa\u4e8eEvent Stream\u4e0e\u670d\u52a1\u5668\u63a8\u9001\u7684\u9ad8\u6548\u5b9e\u73b0\u65b9\u6848 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb837\u6b21\uff0c\u70b9\u8d5e29\u6b21\uff0c\u6536\u85cf30\u6b21\u3002\u901a\u8fc7\u6574\u5408\u4e0e\u6d41\u5f0f\u6e32\u67d3\u6280\u672f\uff0c\u524d\u7aef\u5e94\u7528\u80fd\u591f\u5728\u5b9e\u65f6\u6570\u636e\u5904\u7406\u548c\u6e32\u67d3\u6027\u80fd\u4e0a\u5b9e\u73b0\u8d28\u7684\u98de\u8dc3\u3002\u672a\u6765\uff0c\u968f\u7740 WebAssembly \u548c\u8fb9\u7f18\u8ba1\u7b97\u7684\u666e\u53ca\uff0c\u5b9e\u65f6\u6570\u636e\u6d41\u7684\u5904\u7406\u6548\u7387\u5c06\u8fdb\u4e00\u6b65\u63d0\u5347\uff0c\u800c AI \u9a71\u52a8\u7684\u52a8\u6001\u6e32\u67d3\u4f18\u5316\uff08\u5982\u9884\u6d4b\u6027\u52a0\u8f7d\uff09\u4e5f\u5c06\u6210\u4e3a\u65b0\u7684\u7814\u7a76\u65b9\u5411\u3002_event-stream\u6d41\u683c\u5f0f\u5904\u7406","og_url":"https:\/\/www.wsisp.com\/helps\/54563.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-12T23:50:31+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812235027-689bd343a0cdf.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/54563.html","url":"https:\/\/www.wsisp.com\/helps\/54563.html","name":"\u524d\u7aef\u5b9e\u65f6\u6570\u636e\u6d41\u5904\u7406\u4e0e\u6d41\u5f0f\u6e32\u67d3\u6027\u80fd\u4f18\u5316\uff1a\u57fa\u4e8eEvent Stream\u4e0e\u670d\u52a1\u5668\u63a8\u9001\u7684\u9ad8\u6548\u5b9e\u73b0\u65b9\u6848 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-12T23:50:31+00:00","dateModified":"2025-08-12T23:50:31+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/54563.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/54563.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/54563.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u524d\u7aef\u5b9e\u65f6\u6570\u636e\u6d41\u5904\u7406\u4e0e\u6d41\u5f0f\u6e32\u67d3\u6027\u80fd\u4f18\u5316\uff1a\u57fa\u4e8eEvent Stream\u4e0e\u670d\u52a1\u5668\u63a8\u9001\u7684\u9ad8\u6548\u5b9e\u73b0\u65b9\u6848"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/54563","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=54563"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/54563\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/54558"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=54563"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=54563"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=54563"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=54563"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}