Build Your Own Information Environment
+
This website explains how to use the DB morph (PartsBin/BYOIE), and what magic it does.
Try it out ...
Open the PartsBin on category BYOIE, and pull out a DB.
When the morph is loaded (onLoad), it connects to the store on the server.
The DB morph contains from top to bottom a search field, a list of elements, a filtering area, and a save area. The search field and the filtering area both allow to reduce the number of displayed elements. Searching searches through all texts in the model and shows elements which have one text with all search terms in them. Both, the filter and the save area work by picking up morphs and dropping them in the respective boxes.
In general, the name of the morph which is used with this synchronization schema is important. If you pick up an element from the list, the DB will open its form and display the model in it, similar to how the PartsBin does it. On the other hand, if you have a morph named 'A' and drop it in the save area, it is added as a an instance of 'A', and using the lively.persistence.StateSync.SynchronizedMorphMixin behavior we try to keep it synchronized with other morphs (in possibly other worlds) which display the same model.
There are some default values for basic input morphs such as Text or List, what to synchronize. All of that can be customized, replacing or augmenting the three methods connectTo, getModelData, and mergeWithModelData.
In order to create a synchronized sticky note, create a new blueprint by pulling out a BoxMorph from the PartsBin (i.e. a rectangle). Drop a text field into that rectangle. Rename the text field to 'content', and the morph to 'stickyNote', or the like. Make sure the new parts name is to your liking, because it should not be changed. Drop the sticky note into the save area. There should now be a new entry in the list of elements. If the list is to long, filter it by dropping your morph into the filter area as well. Pull out that same model from the list. Watch it synchronize as you change it, or its original.
In order to have more expressive list element texts, improve the toString output of your morph.
informal documentation and thought structuring aid
X

Menu
Missing signals and affordances
X

Menu
Build Your Own Information Environment Mental Model
+
We are synchronizing simplified versions of a part of the morphic scene graph, i.e. a morph and its submorphs. That simplified version is a model. The scene graph part from which a model is derived is a form.
How a form is recreated for a model, and filled with the models contents: When you have a model, we retrieve the form from the database. All morphs with the same name are considered to have the same morph structure for their model to be displayed in. E.g. if the model is found at path "StickyNote.1", we retrieve the form at "StickyNote['.form']". The form is deserialized, we mix in the SynchronizedMorphMixin into the recreated morph. That also connects to the database and starts listening on model changes. Last, we apply the model, walking the scene graph and calling mergeWithModelData (someValue, changeTime).
When is the model saved? When it changes :). The model is assumed to have changed when the save method is called on the synchronized object. Both of those information are supplied to synchronized morph submorphs via connectTo (targetObject, targetMethod, options). ConnectTo is called whenever the morph is saved or recreated. The three arguments can be passed to a connection to the save indicating attribute, like textString on TextMorphs, or call targetObject[targetMethod](newValue, source [, connection]), ignoring the options.
How the model is created from a morph: When you have a scene graph part (i.e. a morph and its submorphs, e.g. from the PartsBin), we create a model by walking the graph and looking for morphs with a name and getModelData method, which is called an the result added to the model.
For basic input morphs such as Text, CodeEditor, CheckBox, List, and Slider, we synchronize their value, i.e. getRichTextMarkup(), savedTextString, checked, itemList, and value.