Skip to content

Commit e1625c2

Browse files
FalkWolskygitbook-bot
authored andcommitted
GITBOOK-155: Added example of Temporary state & Transformers to Gitbook
1 parent bf6cd07 commit e1625c2

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

docs/business-logic-in-apps/write-javascript/temporary-state.md

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,22 +79,10 @@ state2.setIn([1],"foo") // this will result to ["hello", "foo"]
7979

8080
You can also call these two methods in event handlers. Select **Set temporary state** as the action and choose method on demand.
8181

82-
## Example: Increment counter
82+
## Example: Multiple Steps Job application app
8383

84-
In this example, the counter tracks the number of button clicks. Every time the user clicks the button, the number in the text component increases by one.
84+
In this example, we are building an app via which an Applicant can apply for a job by going via different steps. We will use Temporary state variable to store data on each step, and will show all the data on the final step from Temporary state variable.
8585

86-
Build an increment counter in following steps:
86+
The following demo shows all the steps of creating this app, and explains in detail the usage of Temporary state : 
8787

88-
1. Add a button component `button1` and a text component `text1`.
89-
2. Create a temporary state `state1`, set its initial value as `0`. Bind `{{state1.value}}` as the display text of `text1`.
90-
3. Add an event handler for `button1`. Select the action **Set temporary state** and the method **setValue**, and then set `{{state1.value+1}}` as the value.
91-
4. Click the button, you can see the value of `text1` increases by one each time you click.
92-
93-
You can also achieve the same result using JavaScript queries:
94-
95-
1. Add a new query, select **Run JavaScript code**.
96-
2. Write JavaScript query with this code, and set it to be manually invoked:\
97-
`state1.setValue(state1.value + 1)`
98-
3. Add an event handler of `button1` to run `query1`.
99-
100-
Now click the **Increment counter** button, you should see the same result as above.
88+
{% embed url="https://app.supademo.com/demo/clyikd4yd03wbphh054on5hh2" %}

docs/business-logic-in-apps/write-javascript/transformers.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,11 @@ Instead, calling the method `setText()` in a JavaScript query reports no error.
6363
In another example, transformer`sort1` aims at sorting the data of `getUsers` by `first_name`, but the `sort()` method may change the original data, so an error occurs.
6464

6565
In this case, use the method `_.orderBy()` provided by [lodash](https://lodash.com/) instead.
66+
67+
## Example: Calculating Average via Transformers
68+
69+
In this example, we are building an app via which an Applicant can apply for a job by going via different steps. We will use Temporary state variable to store data on each step, and will show all the data on the final step from Temporary state variable.
70+
71+
The following demo shows all the steps of creating this app, and explains in detail the usage of Temporary state : 
72+
73+
{% embed url="https://app.supademo.com/demo/clyohuj2r0sluy805bs0e8mru" %}

0 commit comments

Comments
 (0)