Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
An example of how to compose DynamicComposableModel instances
m := DynamicComposableModel new.
m instantiateModels: #( list ListModel ).
m list items: (AbstractWidgetModel allSubclasses sorted: [:a :b | a name < b name ]).
m layout: (SpecLayout composed
add: #list;
m openWithSpec.
m2 := DynamicComposableModel new.
m2 assign: m to: #classes.
m2 instantiateModels: #( methods ListModel ).
m list whenSelectedItemChanged: [ :item |
ifNil: [ m2 methods: #() ]
ifNotNil: [ m2 methods items: ((item selectorsInProtocol: 'protocol') sorted) ] ].
m2 layout: (SpecLayout composed
newRow: [ :r | r add: #classes; add: #methods ];
m2 openWithSpec.
m3 := DynamicComposableModel new.
m3 assign: m2 to: #top.
m3 instantiateModels: #( text TextModel ).
m2 methods whenSelectedItemChanged: [ :selector |
selector ifNil: [ m3 text text: '' ] ifNotNil: [ m3 text text: (m list selectedItem >> selector ) sourceCode ] ].
m3 layout: (SpecLayout composed
newColumn: [ :c | c add: #top; add: #text ];
m3 openWithSpec.
m3 title: 'Protocol browser'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment