You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Migrating.md
+21-21Lines changed: 21 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,24 +16,24 @@ import {
16
16
component,
17
17
+ observer,
18
18
- mixin,
19
-
+ WebCell,
20
-
createCell,
21
-
Fragment
19
+
- createCell,
20
+
- Fragment
22
21
} from 'web-cell';
23
22
+import { observable } from 'mobx';
24
23
25
24
-interface State {
26
25
+class State {
27
26
+ @observable
28
-
key: string;
27
+
- key: string;
28
+
+ accessor key = '';
29
29
}
30
30
31
31
@component({
32
32
tagName: 'my-tag'
33
33
})
34
34
+@observer
35
35
-export class MyTag extends mixin<{}, State>() {
36
-
+export class MyTag extends WebCell() {
36
+
+export class MyTag extends HTMLElement {
37
37
- state: Readonly<State> = {
38
38
- key: 'value'
39
39
- };
@@ -57,7 +57,7 @@ At the same time, `shouldUpdate() {}` life-cycle has been dropped. You just need
57
57
MobX's [`@observable`][4] & [`reaction()`][5] are awesome APIs to implement these above with clear codes, so we add `mobx` package as a dependency:
58
58
59
59
```shell
60
-
npm install mobx@5
60
+
npm install mobx
61
61
```
62
62
63
63
On the other hand, [`mobx-web-cell` adapter][6] has been merged into the core package. And cause of replacing **Prototype Overwrite** with **Class Inheritance** to refactor **Class Mixins**, `@observer` decorator should follow strict order to make observation work:
0 commit comments