From fdcdcfffd3f851171c41c4be662cce4e8098d582 Mon Sep 17 00:00:00 2001 From: anekos Date: Thu, 5 Aug 2010 18:46:31 +0000 Subject: 終了処理の変更&ストリームを切断するように git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@38193 d0d07461-0603-4401-acd4-de1884942a52 --- twittperator.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'twittperator.js') diff --git a/twittperator.js b/twittperator.js index 3253246..aa23b0d 100755 --- a/twittperator.js +++ b/twittperator.js @@ -1076,17 +1076,17 @@ let (m = s.match(/https?:\/\/[\S]+/)) (m && m[0]); - function stop() { - let prev = debugVars.prev; + let connectionInfo; - if (!prev) + function stop() { + if (!connectionInfo) return; - clearInterval(prev.interval); - prev.sos.close(); - prev.sis.close(); + clearInterval(connectionInfo.interval); + connectionInfo.sos.close(); + connectionInfo.sis.close(); - delete debugVars.prev; + connectionInfo = void 0; } function start() { @@ -1146,7 +1146,7 @@ } }, 500); - debugVars.prev = { + connectionInfo = { sos: sos, sis: sis, interval: interval, @@ -1650,16 +1650,11 @@ function loadPlugins() { // {{{ accessor.set("consumerKey", "GQWob4E5tCHVQnEVPvmorQ"); accessor.set("consumerSecret", "gVwj45GaW6Sp7gdua6UFyiF910ffIety0sD1dv36Cz8"); - if (!__context__.hasOwnProperty("__debugVars__")) - __context__.__debugVars__ = {}; - let debugVars = __context__.__debugVars__; - let history; if (__context__.Tweets) { history = __context__.Tweets; } else { history = __context__.Tweets = accessor.get("history", []); - liberator.registerObserver("exit", function() accessor.set("history", history)); } let tw = new TwitterOauth(accessor); @@ -1671,6 +1666,11 @@ function loadPlugins() { // {{{ if (setting.useChirp) ChirpUserStream.start(); + + __context__.onUnload = function () { + accessor.set("history", history); + ChirpUserStream.stop(); + }; // }}} })(); -- cgit v1.2.3