回答編集履歴

1

追記

2020/09/24 12:09

投稿

AkitoshiManabe
AkitoshiManabe

スコア5432

test CHANGED
@@ -75,3 +75,47 @@
75
75
  // => {sample: "SAMPLE"}
76
76
 
77
77
  ```
78
+
79
+ 追記)
80
+
81
+
82
+
83
+ fetch の遅延を考える
84
+
85
+
86
+
87
+ ```javascript
88
+
89
+ /* omitted */
90
+
91
+ fetchData() {
92
+
93
+ fetch('sample.json')
94
+
95
+ .then(res => res.json())
96
+
97
+ .then( json => {
98
+
99
+ this.data = json;
100
+
101
+ if( "function" === typeof this.onload ) {
102
+
103
+ this.onload(this);
104
+
105
+ }
106
+
107
+ })
108
+
109
+ }
110
+
111
+ /* omitted */
112
+
113
+ const a = new A();
114
+
115
+ a.b.c.onload = function(c){
116
+
117
+ alert(JSON.stringify(c.data));
118
+
119
+ }
120
+
121
+ ```