-
Notifications
You must be signed in to change notification settings - Fork 0
No Widget Is An Island
This is an easy mission with profound implications. You simply have to navigate a tree of Matrix objects, or models, from a provided node to find a clearly specified target node, and return it. The peovided code handles the rest.
What makes this easy is that all models know their parent, and may know a vector of children. So, yes, you can get there from here.
We provide a utility that searches such a tree, and that utility takes parameters so you can control where it looks if needed, while simpler utilties let you navigate more, well, simply.
We even provide a visualization of the tree to help you think about the navigation.
What makes this profound is that:
- a Matrix application is largely one such tree, comprising all interesting application state; and
- every model property formula is passed the model as its sole parameter; and
- every event handler can derive its owning model.
When writing formulas or event handlers, the world is our oyster.
Learn to navigate the Matrix tree of models.
ReactJS introduced the world to declarative GUIs, but went awry by fussing over purity.
The simple fact is that powerful GUIs mean sharing state, because different widgets often reflect the same state; e.g., a "delete" button will be disabled or not even visible if nothing to delete has been selected. This was the first thing we wanted to do with ReactJS and it did not go well because, in our design, the garbage can delete icon was in a toolbar, not sitting on the ToDo item as specified in the TodoMVC spec.
React "props" were great for customizing reusable widgets, but not for passing around changing information as the user worked. They tried passing around callbacks so widgets could work together, and conceived and simultaneously deprecated context, but it was not good.
So they conceived Flux, which led to Redux, Vuex, and others. That worked and was a prima facie good way of dividing and conquering GUI app coplexity, but was cumbersome and verbose. So now they have Redux Toolkit and hooks and have let context out of jail...stay tuned.
Matrix embraces the idea that complex applications are deeply interdependent, especially GUI applications. Matrix allows derived state to use arbitrary other state without restriction.
Well, cycles throw an exception, but we could work around that, if needed. We just have not needed it yet.
In the "Hello, Cells" intro, we deliberately stuck to one property of one widget, so no navigation to other widgets was needed.
To accomplish this Mission, you will use Matrix search utilities to find the state you need for one widget amongst the state of other widgets. This will include both mutating arbitrary state (omnipotence) and keeping track of mutations (omnipotence) to display a widget according to the spec.
Help learning mxWeb is available on the #matrix channel of Clojurians Slack.
Issues with this trainer can be reported on its GitHub repo.