TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

How Custom Javascript Events Will Save the Universe

2 点作者 mcxx将近 15 年前

1 comment

kls将近 15 年前
I agree using a pub / sub event model can help to decouple a UI and allow developers to build components that can be dropped in pages. For example I use event models to notify widgets that new data is available. If someone changes their account information I publish an account changed message and any subscribers are get the new data and are responsible for updating their UI. Further the one I love to use it for is analytical. When you write widgets that you will use over and over again, I never know what analytical library that a company will be using so setting all my track-able events up as event publishes allows me to write a module that can subscribe to the events and publish the data to Omniture, Unica, Google or whoever. This decouples the two and allows the analytical to be layered on after the fact.