[squeak-dev] The Inbox: Monticello-ct.712.mcz

Jakob Reschke forums.jakob at resfarm.de
Wed Jan 15 20:32:58 UTC 2020


Am Mi., 15. Jan. 2020 um 09:13 Uhr schrieb Thiede, Christoph <
Christoph.Thiede at student.hpi.uni-potsdam.de>:

> You proposed using a promise - I never had the pleasure to meet them until
> today. Maybe you have a minimum working example for demonstrating your
> proposal? FutureNodes seem to be used very rarely in Trunk :-)
>
I have no minimum example ready, but here is the outline:
- Add an instance variable for the promise to the model.
- Initialize with `Promise new` when the model is asked to open a view.
- Answer the promise to the open message.
- In the model's method that is invoked when the dialog is accepted,
promise resolveWith: theResultOfWhatHappened
- In the method that opens the tool, take the promise and use
whenResolved:, whenRejected: (handle the outcome) or then:ifRejected:
(handle the outcome and answer another promise -- chaining). Do not attempt
to return from the handler blocks, the method will have returned by the
time they are evaluated.

Of course it is a totally different style of programming than with modal
windows.

Similar alternative without promises:
- Instead of a promise, store a MessageSend in the model.
- In the client of the model, store all necessary state to continue in
instance variables.
- Do not expect a return value from opening the view for the model.
- Have the model send the message to self upon continuation.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200115/ca862f5c/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 120686 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200115/ca862f5c/attachment-0001.png>


More information about the Squeak-dev mailing list