This is part of a tutorial series on creating extension components for Design Studio.
Before we actually start making use of the properties that we defined in the last session, we need to take a side trip into theory. We'll do this in order to spare you hair pulling moments, later on, when you can't figure out why your properties are "working" sometimes, but not at other times.
Where the Properties Are
The fist thing to keep in mind is that component properties live in two or three places, depending on whether we are running in the designer, or whether the app is running and being accessed via a browser. The three possible places are:
When and how they are synchronized
There are two simple rules for how properties are synchronized:
That's it! Now let's take a look at what this means in practice.
Examples
As we're keeping two or three copies of all of our properties, we need a way to make sure that they are all synchronized. How exactly this is done depends on where the value is changed. In the following examples, let's presume that all copies of some hypothetical property start with the value "A" and we'll change it to "B".
If the change happens on the properties sheet, during design time:
These property changes will be saved in the app.
If the change happens on the APS, during design time:
These property changes will be saved in the app.
If the change happens on the client, during run time:
If the change happens on the server, during run time (it was set via BIAL script):
Mistakes and Pitfalls. Things go bad when...
So far, we've covered the scenarios that are supposed to work. There are also mistakes and pitfalls to watch out for.
If the change happens on the canvas, during design time:
These property changes will not be saved in the app.
There is no "initial push" of property values from the server. Only changed values are propagated. This means that if I don't change a value from the default via the properties pane, no property value will be pushed to the client. So if A is the default value in the properties pane and the designer never changes it, then it will be undefined in the client and APS. The solution to this is to explicitly initialize every property in the APS and component.js. Yes, it is tedious, but it will save you from wondering why the property is undefined in the client some times, but not others.
Forgetting to fire firePropertiesChanged() will also result in different property values being on the server and client.
As always, the completed extension (as of part 3) is available as a Github repository.
Next time, we'll put this theory into practice and start using our properties to define our gauge.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
10 | |
10 | |
9 | |
8 | |
8 | |
6 | |
6 | |
5 | |
5 |