avatar
文章
12
標籤
22
分類
19
關於我
HAO Lab
關於我

HAO Lab

你可能不知道的 NestJS 隱藏技巧:Discovery Module
發表於2023-09-17|更新於2023-09-17|BackendNestJSAdvanced|Backend•NestJS
在某些應用場景下,可能會需要去遍歷封裝於 模組(Module) 內的元件,比如:找出帶有特定 裝飾器(Decorator) 的元件,甚至是元件底下的方法,來預先處理一些事情,最典型的案例就是 EventEmitterModule,當某個事件觸發時,會呼叫帶有特定裝飾器的方法。 NOTE:關於 EventEmitterModule 可以參考官方文件的說明。 下方是官方 EventEmitterModule 的範例,透過 EventEmitter2 發送 order.created 事件時,會呼叫帶有 @OnEvent 裝飾器且值為 order.created 的方法: 1234567this.eventEmitter.emit( 'order.created', new OrderCreatedEvent({ orderId: 1, payload: {}, }),); 123456789// ...@Injectable()export class OrderListener { ...
動態載入 Web Component
發表於2023-09-10|更新於2023-09-10|FrontendWeb Component|Frontend•Angular•Web Component
什麼是 Web Component?Web Component 是一個封裝自定義元件的技術,讓我們可以輕易地在不同應用程式中重用這些被封裝的元件,不僅如此,Web Component 不限定應用程式使用的框架或函式庫,不論今天是 Angular 或 React,甚至是 Vanilla JavaScript 都能夠輕鬆使用。 INFO:關於 Web Component 的詳細資訊可以參考 MDN。 為什麼需要 Web Component?Web Component 的問世,可以實現較理想的 微前端(Micro Frontend) 概念,在過去,會以 iframe 的形式將其他團隊開發的元件、頁面嵌入至自己的系統內來實現微前端,但這樣的做法會有很多的限制,比如:跨域、生命週期等。 透過 Web Component 則可以避免這些問題,因為概念上就是將其他團隊開發的元件程式碼嵌入並串接至自己的系統裡。 NOTE:微前端也可以用 Module Federation 技術來實作,有興趣的話,可以參考相關文件。 動態載入 Web Component目前常見的 Web...
12
avatar
HAO
樂於分享與熱愛學習的工程師
文章
12
標籤
22
分類
19
公告
全世界第一本繁體中文 NestJS 入門書籍已上架,歡迎點擊這裡前往購買!
最新文章
AI 時代下如何建立團隊的 AI 工作流2026-06-07
用 Temporal 實現 Orchestration Saga2026-01-05
用 Idle detection API 檢測用戶狀態2025-10-11
用 Air 實現 Live Reload 加速開發 Golang 應用2025-07-12
Zog 簡介2025-06-28
分類
  • Backend6
    • KrakenD1
    • NestJS4
      • Advanced1
      • Contract Testing2
    • Saga1
      • Temporal1
        • Golang1
標籤
AI Golang Backend Web Component Pact Harness Engineering Spec-Driven Development Cache DevTool Contract Testing KrakenD Web APIs Temporal APIGateway Valkey Saga NestJS Angular Frontend Software Engineering Pact Broker Validation
歸檔
  • 六月 2026 1
  • 一月 2026 1
  • 十月 2025 1
  • 七月 2025 1
  • 六月 2025 1
  • 五月 2025 1
  • 四月 2025 1
  • 三月 2025 1
網站資訊
文章數量 :
12
訪客數 :
總瀏覽量 :
最後更新時間 :
推薦 Blog
hcLuo Blog
Leo's Coding Life
©2023 - 2026 By HAO
框架 Hexo 7.3.0|主題 Butterfly 5.3.5