关于变化的类事件,pharo

发布于 2024-12-13 08:19:35 字数 58 浏览 0 评论 0原文

是否可以监听类在更改时引发的事件?我需要知道系统浏览器中某些类的某些内容(代码、变量等)何时发生变化。

Is it possible to listen events that classes throw when changed? I need to know when something (code, variables, etc) changes in some classes from the system browser.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

巨坚强 2024-12-20 08:19:35

请注意,从 Pharo 2.0 开始,现在有一个 SystemAnnouncer 可以发出公告。不再有 SystemChangeNotifier。

 SystemAnnouncer uniqueInstance 

是访问它的方式。然后查看包系统公告

您可以使用注册

SystemAnnouncer uniqueInstance on: ClassRenamed do: [ doSomething ]

SystemAnnouncer uniqueInstance on: ClassRenamed send: #foo to: anObject

您可以使用取消订阅

SystemAnnouncer uniqueInstanceunsubscribe: anObject

Pay attention since Pharo 2.0, there is now a SystemAnnouncer that emits announcements. There is not SystemChangeNotifier anymore.

 SystemAnnouncer uniqueInstance 

is the way to access it. Then look in the package System-Announcements

You can register using

SystemAnnouncer uniqueInstance on: ClassRenamed do: [ doSomething ]

or

SystemAnnouncer uniqueInstance on: ClassRenamed send: #foo to: anObject

You can unsubscribe using

SystemAnnouncer uniqueInstanceunsubscribe: anObject
各空 2024-12-20 08:19:35

SystemChangeNotifier uniqueInstance 是管理系统更改事件(代码和变量更改所属)的对象。查看对 SystemChangeNotifier 的引用可以找到许多示例用户。

例如,要收到有关所有更改的通知(可以使用其他注册方法,仅注册更改的子集):

SystemChangeNotifier uniqueInstance
  notify: self ofAllSystemChangesUsing: #systemEvent:

从现在开始,使用 AbstractEvent 的子类实例调用方法 systemEvent: 代表所有更改。

要摆脱进一步的通知,请执行:

SystemChangeNotifier uniqueInstance
  noMoreNotificationsFor: self

SystemChangeNotifier uniqueInstance is the object managing the system change events (to which code and variable changes belong). Have a look at the references to SystemChangeNotifier to find many example users.

For example, to be notified about all changes (other registration methods are available that only register for a subset of changes):

SystemChangeNotifier uniqueInstance
  notify: self ofAllSystemChangesUsing: #systemEvent:

The method systemEvent: is from now on called with instances of subclasses of AbstractEvent representing all changes.

To get rid of the further notifications execute:

SystemChangeNotifier uniqueInstance
  noMoreNotificationsFor: self
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文