Skip to content

Commit 287cdf0

Browse files
committed
Make minor improvements in list-of-events.md
Also, link to `docs/developer-guide/events/list-of-events.md` in the `README.md`.
1 parent cba1e2b commit 287cdf0

File tree

3 files changed

+158
-113
lines changed

3 files changed

+158
-113
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ the tests are run twice initially.
3030

3131
* [How to develop a collector](docs/developer-guide/collectors/how-to-develop-a-collector.md)
3232
* [How to test rules](docs/developer-guide/rules/how-to-test-rules.md)
33+
* [List of events](docs/developer-guide/events/list-of-events.md)
3334

3435
#### User guides
3536

+148-103
Original file line numberDiff line numberDiff line change
@@ -1,155 +1,200 @@
11
# List of events emitted by a collector
22

3-
`collector`s communicate via events. The following is a list of all the events
4-
commont to all `collector`s, with their signature and the `interface` they implement.
3+
`collector`s communicate via events. The following is a list of all
4+
the events commont to all `collector`s, with their signature and the
5+
`interface` they implement.
6+
57

68
## `targetfetch::start`
79

8-
* **When?** When the `collector` is about to start the request to fetch the `target`.
10+
* **When?** When the `collector` is about to start the request to
11+
fetch the `target`.
12+
913
* **Format**
10-
```typescript
11-
export interface IFetchStartEvent {
12-
/** The url to download */
13-
resource: string;
14-
}
15-
```
14+
15+
```typescript
16+
export interface IFetchStartEvent {
17+
/** The URL to download */
18+
resource: string;
19+
}
20+
```
21+
1622
* **Remarks:** The event is the same for [`fetch::start`](#fetch::start)
1723

24+
1825
## `targetfetch::end`
1926

20-
* **When?** When the `collector` has finished downloading the `html` of the `target`.
27+
* **When?** When the `collector` has finished downloading the `target`.
28+
2129
* **Format**
22-
```typescript
23-
export interface IFetchEndEvent {
24-
/** The element that initiated the request. */
25-
element: IAsyncHTMLElement;
26-
/** The url of the target. */
27-
resource: string;
28-
/** The request made to fetch the target. */
29-
request: IRequest;
30-
/** The response sent while fetching the target. */
31-
response: IResponse;
32-
}
33-
```
34-
* **Remarks:** The event is the same for [`fetch::end`](#fetch::end). In this case `element` will be null.
30+
31+
```typescript
32+
export interface IFetchEndEvent {
33+
/** The element that initiated the request. */
34+
element: IAsyncHTMLElement;
35+
/** The URL of the target. */
36+
resource: string;
37+
/** The request made to fetch the target. */
38+
request: IRequest;
39+
/** The response sent while fetching the target. */
40+
response: IResponse;
41+
}
42+
```
43+
44+
* **Remarks:** The event is the same for [`fetch::end`](#fetch::end).
45+
In this case `element` will be null.
46+
3547

3648
## `targetfetch::error`
3749

38-
* **When?** When the `collector` has found a problem downloading the `html` of the `target`.
50+
* **When?** When the `collector` has found a problem downloading
51+
the `target`.
52+
3953
* **Format**
40-
```typescript
41-
export interface IFetchErrorEvent {
42-
/** The url of the target. */
43-
resource: string;
44-
/** The element that initiated the request. */
45-
element: IAsyncHTMLElement;
46-
/** The error found. */
47-
error: any;
48-
}
49-
```
50-
* **Remarks:** The event is the same for [`fetch::error`](#fetch::error). In this case `element` will be null.
54+
55+
```typescript
56+
export interface IFetchErrorEvent {
57+
/** The URL of the target. */
58+
resource: string;
59+
/** The element that initiated the request. */
60+
element: IAsyncHTMLElement;
61+
/** The error found. */
62+
error: any;
63+
}
64+
```
65+
* **Remarks:** The event is the same for [`fetch::error`](#fetch::error).
66+
In this case `element` will be null.
67+
5168

5269
## `fetch::start`
53-
* **When?** When the `collector` is about to start the request to fetch the `target`.
70+
71+
* **When?** When the `collector` is about to start the request to
72+
fetch the `target`.
73+
5474
* **Format**
55-
```typescript
56-
export interface IFetchStartEvent {
57-
/** The url to download */
58-
resource: string;
59-
}
60-
```
75+
76+
```typescript
77+
export interface IFetchStartEvent {
78+
/** The URL to download */
79+
resource: string;
80+
}
81+
```
82+
6183
* **Remarks:** The event is the same for [`targetfetch::start`](#targetfetch::start).
6284

85+
6386
## `fetch::end`
6487

65-
* **When?** When the `collector` has finished downloading the content of a `resource` (`js`, `css`, `image`, etc.).
88+
* **When?** When the `collector` has finished downloading the content
89+
of a `resource` (`js`, `css`, `image`, etc.).
90+
6691
* **Format**
67-
```typescript
68-
export interface IFetchEndEvent {
69-
/** The element that initiated the request. */
70-
element: IAsyncHTMLElement;
71-
/** The url of the target */
72-
resource: string;
73-
/** The request made to fetch the target. */
74-
request: IRequest;
75-
/** The response sent while fetching the target. */
76-
response: IResponse;
77-
}
78-
```
92+
93+
```typescript
94+
export interface IFetchEndEvent {
95+
/** The element that initiated the request. */
96+
element: IAsyncHTMLElement;
97+
/** The URL of the target */
98+
resource: string;
99+
/** The request made to fetch the target. */
100+
request: IRequest;
101+
/** The response sent while fetching the target. */
102+
response: IResponse;
103+
}
104+
```
105+
79106
* **Remarks:** The event is the same for [`targetfetch::end`](#targetfetch::end).
80107

81108
## `fetch::error`
82109

83-
* **When?** When the `collector` has found a problem downloading the content of a `resource`.
110+
* **When?** When the `collector` has found a problem downloading
111+
the content of a `resource`.
112+
84113
* **Format**
85-
```typescript
86-
export interface IFetchErrorEvent {
87-
/** The url of the target. */
88-
resource: string;
89-
/** The element that initiated the request. */
90-
element: IAsyncHTMLElement;
91-
/** The error found. */
92-
error: any;
93-
}
94-
```
114+
115+
```typescript
116+
export interface IFetchErrorEvent {
117+
/** The URL of the target. */
118+
resource: string;
119+
/** The element that initiated the request. */
120+
element: IAsyncHTMLElement;
121+
/** The error found. */
122+
error: any;
123+
}
124+
```
125+
95126
* **Remarks:** The event is the same for [`targetfetch::error`](#targetfetch::error).
96127

128+
97129
## `traverse::start`
98130

99131
* **When?** When the `collector` is going to start traversing the DOM.
132+
100133
* **Format**
101-
```typescript
102-
export interface ITraverseStartEvent {
103-
/** The url of the target. */
104-
resource: string;
105-
}
106-
```
134+
135+
```typescript
136+
export interface ITraverseStartEvent {
137+
/** The URL of the target. */
138+
resource: string;
139+
}
140+
```
141+
107142

108143
## `traverse::end`
109144

110145
* **When?** When the `collector` has finished traversing the DOM entirely.
146+
111147
* **Format**
112-
```typescript
113-
export interface ITraverseEndEvent {
114-
/** The url of the target. */
115-
resource: string;
116-
}
117-
```
148+
149+
```typescript
150+
export interface ITraverseEndEvent {
151+
/** The URL of the target. */
152+
resource: string;
153+
}
154+
```
155+
118156

119157
## `traverse::down`
120158

121-
* **When?** When the `collector` is traversing and starts visiting the children
122-
of a node.
159+
* **When?** When the `collector` is traversing and starts visiting
160+
the children of a node.
161+
123162
* **Format**
124-
```typescript
125-
export interface ITraverseDownEvent {
126-
/** The url of the target. */
127-
resource: string;
128-
}
129-
```
163+
164+
```typescript
165+
export interface ITraverseDownEvent {
166+
/** The URL of the target. */
167+
resource: string;
168+
}
169+
```
130170

131171
## `traverse::up`
132172

133-
* **When?** When the `collector` has finsihed visting the children of a node and goes to the next one.
173+
* **When?** When the `collector` has finsihed visting the children
174+
of a node and goes to the next one.
134175

135176
* **Format**
136-
```typescript
137-
export interface ITraverseUpEvent {
138-
/** The url of the target. */
139-
resource: string;
140-
}
141-
```
142177

143-
## `element::typeofelement`
178+
```typescript
179+
export interface ITraverseUpEvent {
180+
/** The URL of the target. */
181+
resource: string;
182+
}
183+
```
144184

145-
* **When?** When the `collector` visits an element in the DOM when traversing it. `XXXX` is the `nodeType` lower cased.
185+
## `element::<element-type>`
186+
187+
* **When?** When the `collector` visits an element in the DOM when
188+
traversing it. `<element-type>` is the [`nodeName`](https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeName)
189+
lower cased.
146190

147191
* **Format**
148-
```typescript
149-
export interface IElementFoundEvent {
150-
/** The uri of the resource firing this event. */
151-
resource: string;
152-
/** The visited element. */
153-
element: IAsyncHTMLElement;
154-
}
155-
```
192+
193+
```typescript
194+
export interface IElementFoundEvent {
195+
/** The URI of the resource firing this event. */
196+
resource: string;
197+
/** The visited element. */
198+
element: IAsyncHTMLElement;
199+
}
200+
```

src/lib/interfaces/events.ts

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
import { IAsyncHTMLElement } from './asynchtml';
22
import { IRequest, IResponse } from './network';
33

4-
54
/** The object emited by a collector on `targetfetch::start` or `fetch::start`. */
65
export interface IFetchStartEvent {
7-
/** The url to download. */
6+
/** The URL to download. */
87
resource: string;
98
}
109

1110
/** The object emited by a collector on `targetfetch::end` or `fetch::end`. */
1211
export interface IFetchEndEvent {
1312
/** The element that initiated the request. */
1413
element: IAsyncHTMLElement;
15-
/** The url of the target. */
14+
/** The URL of the target. */
1615
resource: string;
1716
/** The request made to fetch the target. */
1817
request: IRequest;
@@ -22,7 +21,7 @@ export interface IFetchEndEvent {
2221

2322
/** The object emitted by a collector on `targetfetch::error` or `fetch::error` */
2423
export interface IFetchErrorEvent {
25-
/** The url of the target. */
24+
/** The URL of the target. */
2625
resource: string;
2726
/** The element that initiated the request. */
2827
element: IAsyncHTMLElement;
@@ -32,31 +31,31 @@ export interface IFetchErrorEvent {
3231

3332
/** The object emitted by a collector on `traverse::start` */
3433
export interface ITraverseStartEvent {
35-
/** The url of the target. */
34+
/** The URL of the target. */
3635
resource: string;
3736
}
3837

3938
/** The object emitted by a collector on `traverse::end` */
4039
export interface ITraverseEndEvent {
41-
/** The url of the target. */
40+
/** The URL of the target. */
4241
resource: string;
4342
}
4443

4544
/** The object emitted by a collector on `traverse::up` */
4645
export interface ITraverseUpEvent {
47-
/** The url of the target. */
46+
/** The URL of the target. */
4847
resource: string;
4948
}
5049

5150
/** The object emitted by a collector on `traverse::down` */
5251
export interface ITraverseDownEvent {
53-
/** The url of the target. */
52+
/** The URL of the target. */
5453
resource: string;
5554
}
5655

57-
/** The object emited by a collector on `element::typeofelement`. */
56+
/** The object emited by a collector on `element::<element-type>`. */
5857
export interface IElementFoundEvent {
59-
/** The uri of the resource firing this event. */
58+
/** The URI of the resource firing this event. */
6059
resource: string;
6160
/** The visited element. */
6261
element: IAsyncHTMLElement;

0 commit comments

Comments
 (0)