[Cuis-dev] How to use Events?

Philip Bernhart philip.bernhart at posteo.de
Sun Sep 8 23:17:15 PDT 2019


Hello,

I noticed that when I register events with when:send:to:with: with collections
as the with: paramater the contents of the collection the collection
becomes nil on the actually triggered event. Maybe that has something
todo with WeakMessageSend. Anyway an example tells better what I mean:


browserMorph 
	setProperty: #editItemAction 
	toValue: [:repository :record| 
		| flashcardMorph card mapping |
		flashcardMorph _ FlashcardMorph new.
		card _ Flashcard new.
		card question: (record at: #question ifAbsent: '').
		card answer: (record at: #answer ifAbsent: '').
		
		card when: #changed
		     send: #saveRecordMappingWith:
		     to: browser
		     with: {card. record}.

		flashcardMorph model: card.
		flashcardMorph showAnswer.
		flashcardMorph enableEditing.
		flashcardMorph openInWorld ]. 

Then in Flashcard there is a foo method which does:
self triggerEvent: #changed.

Here the {card. record} becomes for some reason (weak reference?) nil
and causes that the event isn't triggered. So #saveRecordMappingWith:
isn't called.

With simple datatypes like Integers this works, with static arrays this
seems to work too.

Maybe this style of doing that isn't the right one, maybe I'm using the
event system for things which it wasn't supposed to do.

Suggestions?


Thanks for your time,
Philip


More information about the Cuis-dev mailing list