Re: Spec ListModel synchronization
Posted by
jfabry on
Mar 30, 2016; 4:05pm
URL: https://forum.world.st/Spec-ListModel-synchronization-tp4887462p4887463.html
Hi Bob,
to answer your 2 questions briefly:
Yes, Spec is here to stay for good, and the idea is that it can compose any kind of widgets, so with a bridge to OSWindow-SDL2 that should work as well.
When changing items in the list, you need to inform the widget of that. To do that you need to call the updateList method on your ListModel instance. So in your example:
aList add: 1.
aListModel updateList.
HTH,
Hello,
It's been a while since I tried out Pharo. I always struggled with Morphic UI's, but I noticed Spec and there seemed to be enough examples floating around that I thought I'd give it another try.
Is Spec "here to stay?" Is it worthwhile to figure it out? It seems like with the developing possibilities of OSWindow-SDL2, one might use Spec to compose native widgets as well.
My main question is about synchronizing domain changes with a Spec UI.
For example, if I create an empty list of items:
aList := OrderedCollection new.
And create and open a ListModel that uses that list:
aListModel := ListModel new
items: aList;
openWithSpec;
yourself.
I get a nice empty list.
If I add an item to my list:
aList add: 1.
Then I need to update the list with another:
aListModel items: aList.
To see it show up.
Alternatively (this seems wrong), I can add an item to the ListModel listItems directly:
aListModel items: (aListModel listItems add: 1; yourself).
Is that basically what you need to do to maintain synchronization between your domain list and the Spec UI representation of that list, or am I missing something?
Thank you,
Rob