/
githubmirror
/
angular
Обзор
Документация
Войти
/
githubmirror
/
angular
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/zone.js/example/web-socket.html
42 строки
1 KB
Matthieu Riegler
ci: reformat files
16 дек 2025, 20:24
16 дек 2025, 20:24
af77b89
Код
Авторство
О чём код?
<!doctype html> <html> <head> <meta charset="utf-8" /> <title>WebSockets with Zones</title> <link rel="stylesheet" href="css/style.css" /> <script src="../dist/zone.js"></script> </head> <body> <p> Ensure that you started <code>node test/ws-server.js</code> before loading this page. Then check console output. </p> <script> var ws = new WebSocket('ws://localhost:8001'); ws.onopen = function () { Zone.current .fork({properties: {secretPayload: 'bah!'}, name: 'secrete-zone'}) .run(function () { ws.onmessage = function (eventListener) { if (Zone.current.get('secretPayload') === 'bah!') { console.log( 'The current zone (id: %s) has secretPayload. Zones are working!', Zone.current.name, ); } else { console.error( 'Secret payload not found where expected! Zones are not working! :-(', Zone.current.name, ); } }; console.log('Setting secret payload in the current zone (id: %s)', Zone.current.name); }); ws.send('hello!'); }; </script> </body> </html>