Skip to content

Commit 40ca737

Browse files
committed
obserbe.off now accepts optional action
1 parent a0b3ac6 commit 40ca737

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ var gmail = Gmail();
9898
- `poll`
9999
- `new_email`
100100
- `refresh`
101-
- gmail.observe **.off()**
101+
- gmail.observe **.off(action)**
102102

103103

104104
### DOM

gmail.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -687,11 +687,17 @@ var Gmail = function() {
687687
}
688688

689689

690-
api.observe.off = function() {
691-
var win = top.document.getElementById("js_frame").contentDocument.defaultView;
692-
win.XMLHttpRequest.prototype.open = api.tracker.xhr_open;
693-
win.XMLHttpRequest.prototype.send = api.tracker.xhr_send;
694-
api.tracker.xhr_init = false
690+
api.observe.off = function(action) {
691+
if(action) {
692+
if(action in self.tracker.watchdog) {
693+
delete self.tracker.watchdog[action];
694+
}
695+
} else {
696+
var win = top.document.getElementById("js_frame").contentDocument.defaultView;
697+
win.XMLHttpRequest.prototype.open = api.tracker.xhr_open;
698+
win.XMLHttpRequest.prototype.send = api.tracker.xhr_send;
699+
api.tracker.xhr_init = false
700+
}
695701
}
696702

697703

0 commit comments

Comments
 (0)