Skip to content

Commit b662099

Browse files
committed
upd
1 parent 2dba84c commit b662099

5 files changed

Lines changed: 70 additions & 4 deletions

File tree

TODO

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@
7878
- [ ] `T!`
7979
- [ ] Statements
8080
- [ ] For `for each`: `Iterator` and `Iterable` are iterable
81+
- [ ] `use effect`
82+
- [ ] `cleanup {}`
8183
- [ ] `switch`
8284
- [ ] No fallthroughs (demonstrate too).
8385
- [ ] `switch type`

src/_BASE/statements/use-effect.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Use effect
2+
3+
The `use effect` statement consists of implementation-defined behavior, however it is usually used to detect state or parameter changes or implement mount and unmount routines for a component.
4+
5+
```
6+
use effect [] {
7+
//
8+
}
9+
use effect [dep1, ...depN] {
10+
//
11+
}
12+
use effect * {
13+
//
14+
}
15+
use effect * {
16+
cleanup {
17+
//
18+
}
19+
}
20+
```

src/lexical-conventions.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,12 @@ type
359359
Embed
360360
final
361361
362+
effect
362363
native
363364
static
364365
366+
cleanup
367+
365368
abstract
366369
override
367370

src/overview/relation/mxml.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,25 @@ package com.business.components {
2121

2222
In MXML, event handlers were expressed as `e="statements"`. In ShockScript, they are expressed as `e&={statements}` (note the ampersand **\&**) as a shorthand to `e={function(event){statements}}`.
2323

24-
> **Note**: Although not demanded as such, as opposed to React.js + DOM, event handlers are conventionally expressed without a `on` prefix, such as `click&={trace("clicked!")}` rather than React.js `onClick={e=>{console.log("clicked!")}}`. Event parameters are conventionally given the `@eventparam` tag in the ShockDoc comments. Classes continue using the `Event` meta-data, though without needing the `@eventType` tag.
24+
> **Note**: Although not demanded as such, as opposed to React.js + DOM, event handlers are conventionally expressed without a `on` prefix, such as `click&={trace("clicked!")}` rather than React.js `onClick={e=>{console.log("clicked!")}}`. Event parameters are conventionally given the `@eventparam` tag in the ShockDoc comments. Classes continue using the `Event` meta-data, though without needing the `@eventType` tag.
25+
26+
## Use effect
27+
28+
The `use effect` statement may be used to detect state and parameter changes as well as the component mount and unmount phases.
29+
30+
```
31+
use effect [] {
32+
//
33+
}
34+
use effect [dep1, ...depN] {
35+
//
36+
}
37+
use effect * {
38+
//
39+
}
40+
use effect * {
41+
cleanup {
42+
//
43+
}
44+
}
45+
```

src/overview/relation/reactjs.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,34 @@ package com.business.components {
102102
[Reference]
103103
var button:Button? = null;
104104
105-
// did mount
106-
Fuse::useEffect(function() {
105+
use effect [] {
107106
trace(button!);
108-
}, []);
107+
}
109108
110109
return (
111110
<j:Button reference={button}>click me</j:Button>
112111
);
113112
}
114113
}
114+
```
115+
116+
## Effects
117+
118+
The popular "use effect" hook is abbreviated as an `use effect` statement.
119+
120+
```
121+
use effect [] {
122+
//
123+
}
124+
use effect [dep1, ...depN] {
125+
//
126+
}
127+
use effect * {
128+
//
129+
}
130+
use effect * {
131+
cleanup {
132+
//
133+
}
134+
}
115135
```

0 commit comments

Comments
 (0)