Closed Updownquark closed 9 years ago
Need to:
I'm kinda just splashing around here. I thought about using rxJava for the observables, but there's a few things I don't really like about it and I'm not sure it fits here. So I starting writing my own. I may backtrack and pull in rxJava later. For now, I want the ObservableValue<T> to extend Observable<ObservableValueEvent<T>> and go from there.
So I've thought more about rxJava and more firmly decided to not integrate it. Because...
I am disappointed to have to reimplement so much work they've done for me, but I can't see a clean way to avoid that.
Started to work on integrating rxJava into MUIS, but it appears rxJava's Observable class was specifically designed NOT to be extensible. So I can't just add values in and I kind of need dynamic type information in them as well. So for now, back to rolling my own rx architecture.
As noted, the initial phase of rx-ifying is done. The next step is to implement a parser for muis model values that can access not only model values but also observables on the element (attributes, etc.) and compose them and operate on them.
I thought of a new extension to this. Have a SettableValue interface which extends ObservableValue and exposes a setter for the value. Certain operations would also support settable composition. For example, a formatting method might also support parsing or the == boolean operator could support a setter (setting to true would assign the value to the other operand; setting to false would assign the value to a default value, also provided by the SettableValue interface). Using this interface, assignment operators could be supported by the model parser.
Need to jot down some ideas.
<toggle-button selected="property==value" />
where setting the attribute's settable to true would set the property to that value. Setting to false would not be allowed.<button action="variable=value" />
where when the button is pushed the value is assigned to the variable. Typically a model value but possibly an attribute or something else. I guess the value returned by this observable would be the right-hand side of the assignment.More thoughts:
The existing MuisProperty interface would change almost not at all. The model value parser interface (which will probably be renamed, since it'll be doing more now) would take a parsing environment, thereby allowing implementations to parse scoped information. A new abstract implementation would be created which provides the extended functionality mentioned above. There would be a document-scope property parser which knows about model values and maybe some other things, but then this abstract implementation would parse things that are more specific to the specific property. When the property is defined it would be initialized with additional parsing configurations and environment variables. A mechanism would also need to be provided for the implementation to evaluate the parsed items generated by the parser. The end value from the parsing will always be an ObservableValue.
There may be some bugs in here (see #58) but this is mostly done and working. I'm gonna call it good and move on to some more creative work and file bugs as I notice them.
Make an Observable interface that has a type, a value and the ability to add listeners. Make these composable. MuisModelValue should extend this. From muis xml, the user should be able to specify expressions that result in a composed observable that depends on many simple ones whose sources maybe model values and maybe attributes, styles, or other element properties. When any one of the sources change, the listeners fire through to the composed observable, which triggers the attribute change. This will involve re-implementing the model value parser and implementing observables for attributes, styles, etc.