[Seaside] registerObjectForBacktracking, submit and execute block

Avi Bryant avi at beta4.com
Mon Aug 30 10:46:32 CEST 2004

On Aug 29, 2004, at 2:43 PM, Andreas Nilsson wrote:

> Ok, that makes sense, didn't know that it used an array internally.
> Any ideas of how to make backtracking work for adding / removing items 
> from a collection?
> Somebody must have tried before ;)

It's a little ugly, and should be encapsulated, but you can use a 
StateHolder holding an Array and use functional operations instead of 
desctructive ones:

	stateHolder := WAStateHolder new contents: #()

	^ stateHolder contents

add: anObject
	stateHolder contents: (self objects copyWith: anObject)

remove: anObject
	stateHolder contents: (self objects copyWithout: anObject)


More information about the Seaside mailing list