5 Editing values in the projection
This chapter covers
- Changing values in existing DSL content
- Introducing edit state in React component functions to implement editability
In chapter 4, we implemented a projection that visualizes an AST as projected DSL content in the DSL’s notation. That AST isn’t going to produce itself, though: we’ll have to extend the Domain IDE so that domain experts can create and change ASTs. To that end, we’re going to turn the projection from chapter 4 into a true editor over the course of this chapter. We’re going to look at how the projection’s current implementation projects each piece of data in the AST and decide how to make that editable piece by piece.
In chapter 6, we’ll see how to add and delete whole AST objects. In the current chapter, we’ll first figure out how to make the individual values of properties’ settings in the AST editable. There are a few different kinds of such property values:
- Free-format textual values, such as the names of record types or their attributes
- Number values, such as the initial value of an attribute
- Values from a fixed set, such as the type of an attribute
- Reference values, such as which attribute is referenced from an
Attribute
Reference
AST object
We’re going to rely in particular on section B.4 in appendix B. It explains how we’ll use the MobX state management library to be able to use the idea of Transparent Functional Reactive Programming (TFRP) to make the projection function reactive.