OLD | NEW |
1 <p> | 1 <p> |
2 An <code>Event</code> is an object | 2 An <code>Event</code> is an object |
3 that allows you to be notified | 3 that allows you to be notified |
4 when something interesting happens. | 4 when something interesting happens. |
5 Here's an example of using the | 5 Here's an example of using the |
6 <code>chrome.tabs.onCreated</code> event | 6 <code>chrome.tabs.onCreated</code> event |
7 to be notified whenever there's a new tab: | 7 to be notified whenever there's a new tab: |
8 </p> | 8 </p> |
9 | 9 |
10 <pre> | 10 <pre> |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 <pre> | 147 <pre> |
148 var rule_ids = ["id1", "id2", ...]; | 148 var rule_ids = ["id1", "id2", ...]; |
149 function getRules(rule_ids, function callback(details) {...}); | 149 function getRules(rule_ids, function callback(details) {...}); |
150 </pre> | 150 </pre> |
151 | 151 |
152 <p> | 152 <p> |
153 The <code>details</code> parameter passed to the <code>calback()</code> function | 153 The <code>details</code> parameter passed to the <code>calback()</code> function |
154 refers to an array of rules including filled optional parameters. | 154 refers to an array of rules including filled optional parameters. |
155 </p> | 155 </p> |
156 </div> | 156 </div> |
157 | |
158 <div class="doc-family extensions"> | |
159 <h2 id="filtered">Filtered events</h2> | |
160 | |
161 <p>Filtered events are a mechanism that allows listeners to specify a subset of | |
162 events that they are interested in. A listener that makes use of a filter won't | |
163 be invoked for events that don't pass the filter, which makes the listening | |
164 code more declarative and efficient - an <a href="event_pages.html">event | |
165 page</a> page need not be woken up to handle events it doesn't care | |
166 about.</p> | |
167 | |
168 <p>Filtered events are intended to allow a transition from manual filtering | |
169 code like this:</p> | |
170 | |
171 <pre> | |
172 chrome.webNavigation.onCommitted.addListener(function(e) { | |
173 if (hasHostSuffix(e.url, 'google.com') || | |
174 hasHostSuffix(e.url, 'google.com.au')) { | |
175 // ... | |
176 } | |
177 }); | |
178 </pre> | |
179 | |
180 <p>into this:</p> | |
181 | |
182 <pre> | |
183 chrome.webNavigation.onCommitted.addListener(function(e) { | |
184 // ... | |
185 }, {url: [{hostSuffix: 'google.com'}, | |
186 {hostSuffix: 'google.com.au'}]}); | |
187 </pre> | |
188 | |
189 <p>Events support specific filters that are meaningful to that event. The list | |
190 of filters that an event supports will be listed in the documentation for that | |
191 event in the "filters" section.</p> | |
192 | |
193 <p>When matching URLs (as in the example above), event filters support the same | |
194 URL matching capabilities as expressable with a <a | |
195 href="events.html#type-UrlFilter">UrlFilter</a>, except for scheme and port | |
196 matching.</p> | |
197 | |
198 </div> | |
OLD | NEW |