Skip to content

Commit e8fdf48

Browse files
committed
notes updates
1 parent a4b9527 commit e8fdf48

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

notes/04-helpers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function padLeadingZeroes(val, digits) {
5656
/**
5757
* Create a string representation of a Date
5858
* @param {string|number|Date} date
59-
* @returns {string|null}
59+
* @returns {string}
6060
*/
6161
export function dateToString(date) {
6262
if (

notes/08-tracked-properties.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Tracked Properties & Derived State
2+
3+
Ember Octane's `tracked` property system allows us to decorate our lowest-level mutable state, and then (for the most part) treat anything downstream as if it's regular modern JavaScript.
4+
5+
Let's use tracked properties to enhance our login form in the following ways:
6+
7+
- We should have a class field `userId` that's kept in sync with the `<select>`'s valuee
8+
- The example validation message should be replaced with `"Logging in with userId {{this.userId}}"`, and should only be displayed if/when a valid `userId` is present
9+
- We should have an `isDisabled` field that indicates whether the form has an invalid `userId` or not
10+
- The `input[type="submit"]` should be disabled whenever `isDisabled` is true
11+
- `onLoginFormSubmit` should only call `handleSignIn` if `isDisabled` is false
12+
- Minimal updates to tests if any of them break (we'll do more meaningful testing next)
13+
14+
Let's get started!
15+
16+
First, we'll need to import the `@tracked` decorator
17+
18+
```js
19+
import { tracked } from '@glimmer/tracking';
20+
```
21+
22+
Next, add the userId class field, and initialize it to `null`
23+
24+
```js
25+
/**
26+
* @type {string}
27+
*/
28+
userId = null;
29+
```
File renamed without changes.

0 commit comments

Comments
 (0)