How to run some Smalltalk code when entering a project
Last updated at 5:27 pm UTC on 29 March 2017
It is possible to run some Smalltalk code when entering or leaving a project.
World when: #aboutToEnterWorld send: #startUp to: anObject.
World when: #aboutToLeaveWorld send: #shutDown to: anObject.
The two events are triggered whenever the world is left or entered (including publishing operations). – (Source: Email by Andreas Raab, February 2002)
- anObject must have some local scope in order to be preserved when the World is entered or left. For instance, a block of code is tossed in the garbage unless you assign it to some local variable. This illustrates the issue:
- World when: #aboutToEnterWorld send: #beep to: Beeper.
- World when: #aboutToEnterWorld send: #value to: [Smalltalk beep].
- the latter is useless, the block is discarded.