On 20 Jan 2014, at 13:51, btc@openinworld.com wrote:I don't want to unsubscribe #refresh in PhLTitledTreeModel>>initialize.
When I try...
��� self whenBuiltDo: [ self halt. self window whenClosedDo: [ self halt. self repository unsubscribe: self ] ].
none of the halts occur.
However I got what I needed with the following�
did you try to register in the initialize method ?Because if you register once the application is already open, it may not work :)
I tried to avoid calling in #windowHolder but would that preferred?
----------
�� ComposableModel>>topWindowHolder
���� ��� ^ owner
��������� ��� � ifNil: [ window ]
����������� ��� ifNotNil: [ :o | o topWindowHolder ].
----------
� ComposableModel>>whenWindowClosed: aBlock
�� �� � self topWindowHolder value
���� �� � � ifNotNil: [ :w | w whenClosedDo: aBlock ]
������ �� � ifNil: [� self topWindowHolder whenChangedDo: [� :w� | w whenClosedDo: aBlock ] ].
----------
��� PhLTitledTreeModel>>repository: aRepository
�� ��� self assert: self repository isNil description: 'Changing the repository is not allowed because we would have to change the context as well'.
��� ��� repositoryHolder value: aRepository.
��� ��� self repository whenChangedSend: #refresh to: self.
��� ��� self whenWindowClosed: [ self repository unsubscribe: self.�� self inform: 'Works for composed sub-items'. ] .
�� �� � self refresh
----------
��� PharoLauncher>>initialize
������� super initialize.
������� self whenWindowClosed: [ self inform: 'Works for top level owner' ].
----------
And optionally you could now have...
��� ComposableModel>>window
��� ��� ^ self topWindowHolder value
�����
topWindowHolder sounds a bit hackish :)
I think this can be achieved with the whenBuiltDo:, I should investigate :)
If those ComposableModel additions are okay, I'll submit a slice on Case 12677 (renamed to "ComposableModel subcomponents need to act on window close")
https://pharo.fogbugz.com/f/cases/12677/
You can also submitted here:�https://github.com/SpecForPharo/spec�if you want :)(and become a Spec contributor :P)
Ben