My First Configurator
The Solid API is a javascript-based API that incorporates solid operations. The operations affect the solid directly and won't be stored like in a history-based approach. Thus, configuring solids means we recreate the solid with new input parameters. This way of configuring we want to apply in this chapter. We will use our lego brick which is actually already prepared for configuring. See My first model. As you remember, we defined two variables, one for the row and one for the columns.
Let's start creating the configurator
- Create a copy of the file "templateConfigurator.ts" which can be found in buerli-examples in models/solid folder
- In the create method we first copy the whole code we implemented in the create method of My first model
This will first do nothing more than run through the code we've already implemented. And as a result, you will, of course, see the same.
The next step will be to create the parameters to set for the rows and columns. There is already a definition for parameters in the template. Add two number parameters to it, one for the number of rows and one for the number of columns.
Start the application again and see how the parameters have been added to your example. If everthings done right, it should look something like that:
Updating one of these number parameters will automatically call the update method of the example. So all we need to do, is to call the initial create method with the updated parameters. Don't forget to replace the hard coded initial values for rows and columns with the incoming parameters. Each time we change the value, the model will be recreated. The update method will look like this: