1.
chatList.html에 <script src="/js/chatting/chatList.js"></script>가 있고
// chatList.js
let loginId;
let eventSource = new EventSource("/sse/chatList");
sse는 스프링부트와 통신하고있는데
브라우저가 chatList.html를 렌더링하다가, chatRoom.html를 렌더링하면
변수 loginId랑 스프링부트와의 sse통신은 어떻게 될까?
>>>
chatList.js는 chatList.html에서만 로드되는 상황.
페이지가 이동하면(chatRoom.html로 전환되면),
chatList.html과 함께 실행 중이던 chatList.js가 종료됨.
chatList.js의 모든 변수(loginId 포함)는 삭제됨
eventSource 객체도 더 이상 유지되지 않으며 자동으로 SSE 연결이 종료됨.
2.
'Programing Language > JavaScript' 카테고리의 다른 글
| Js 싱글스레드와 비동기처리 (0) | 2025.02.25 |
|---|---|
| Js 호이스팅(Hoisting) (0) | 2025.02.25 |
| 코딩하면서 js정리 01 (0) | 2025.02.05 |
| JavaScript engine (1) | 2025.01.28 |
| Js변수 선언 방식 var, let, const (1) | 2025.01.27 |