3

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

4

2 回答 2

5

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

 SystemAnnouncer uniqueInstance 

是访问它的方式。然后查看包System-Announcements

您可以使用注册

SystemAnnouncer uniqueInstance on: ClassRenamed do: [ doSomething ]

或者

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

您可以使用取消订阅

SystemAnnouncer uniqueInstanceunsubscribe: anObject
于 2013-06-30T07:42:47.647 回答
4

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

例如,要获得所有更改的通知(其他注册方法可用,仅注册更改的子集):

SystemChangeNotifier uniqueInstance
  notify: self ofAllSystemChangesUsing: #systemEvent:

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

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

SystemChangeNotifier uniqueInstance
  noMoreNotificationsFor: self
于 2011-11-02T06:00:05.043 回答