Return-Path: X-Original-To: apmail-incubator-callback-dev-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 67440D561 for ; Mon, 27 Aug 2012 16:52:23 +0000 (UTC) Received: (qmail 33303 invoked by uid 500); 27 Aug 2012 16:52:23 -0000 Delivered-To: apmail-incubator-callback-dev-archive@incubator.apache.org Received: (qmail 33272 invoked by uid 500); 27 Aug 2012 16:52:23 -0000 Mailing-List: contact callback-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-dev@incubator.apache.org Received: (qmail 33264 invoked by uid 99); 27 Aug 2012 16:52:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Aug 2012 16:52:23 +0000 X-ASF-Spam-Status: No, hits=2.5 required=5.0 tests=FRT_ADOBE2,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of agrieve@google.com designates 209.85.214.175 as permitted sender) Received: from [209.85.214.175] (HELO mail-ob0-f175.google.com) (209.85.214.175) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Aug 2012 16:52:16 +0000 Received: by obc16 with SMTP id 16so8378301obc.6 for ; Mon, 27 Aug 2012 09:51:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type :x-system-of-record; bh=nhs0wL3r3gaFFjDm8Ownsod15Qx5KP+PEiBoK6OYlAU=; b=jabwMhyzDu3Pdcs5SJbr+BunwL44AuC6HsvuNzF3FNNO4WrrVIHtk36KQuZ/XBrUdf e+UX3zhoqqkhXaR0/KcuK6CTLRzDSp6L7bGx36Pl2XBZbr3EWN+pflslIJekwRattwLl sUryABBoXHD9sHNtzvpH9KESQhDgHV0imuS7G69ugSoUwVQECRhRCUlbVMis5z8mgeFf hONcJn7fEOyABHTnimJuvFDh5k8N6DTRAtYvDXpu2LuAAOvquZ6vdHfUbKf1xf8/7qpi 4RKaxgV6JBR5ZpUQPzFrwiEtOIT2lLOq28hsf1yLH2wI3ew4NNmwx9ZMkvtKClx3siNS k8fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type :x-system-of-record:x-gm-message-state; bh=nhs0wL3r3gaFFjDm8Ownsod15Qx5KP+PEiBoK6OYlAU=; b=QrDMGlY1uxOjV62P0DAxNkqhkANys9Jzanfsf4mh/0HyZRUT8/3QYXLtQSllh9TZuK 9ujm/kDcIFnwBaKFYPuVfgFuJXDoOaYqAcqZHsOw2QtWaMmgsO0arY66LOWK5jCK1N5E 70g70PxhFOkJg31tsLpHxoVSU2d7qFI3VHrR5n0KmKA7cMkdZ2x2Miir4TkLQO8yXVSr ye2LVV7HPR6wyIJ0835jbkadZd53eetOo1WHO4hd0Ufac4lODXA96OCtfo1+JBSz+EeP vwHVE2lS4RFeGNfcVCGeUgp6acdwaD56eoqsxr8UybqouiHSQYOFcWY05XyJL/03ERNg sedg== Received: by 10.182.202.6 with SMTP id ke6mr10456887obc.83.1346086315843; Mon, 27 Aug 2012 09:51:55 -0700 (PDT) Received: by 10.182.202.6 with SMTP id ke6mr10456885obc.83.1346086315739; Mon, 27 Aug 2012 09:51:55 -0700 (PDT) MIME-Version: 1.0 Sender: agrieve@google.com Received: by 10.182.125.71 with HTTP; Mon, 27 Aug 2012 09:51:35 -0700 (PDT) In-Reply-To: References: From: Andrew Grieve Date: Mon, 27 Aug 2012 12:51:35 -0400 X-Google-Sender-Auth: sNFKW1CBHiwaOixCOA4Cn2UpdwY Message-ID: Subject: Re: Channel.fire() and onPause/onResume To: callback-dev@incubator.apache.org Content-Type: multipart/alternative; boundary=e89a8f6434b6afc98804c84224b3 X-System-Of-Record: true X-Gm-Message-State: ALoCoQlY7JBvhz6yIcAott14uQZZUqpiorCPb4BXRTbohN7iVdWNd0dQAenDwCDdaMdTY35cQAONcnL28dPAunrsoRoFTrC9RET6FijrMkZTzHdIeVJ/oKmoVw6zc5b13tw1hpt/6XTTyOwNA3e/YYZGdfZeetBjCx/MFd8kn7A3kvb+jFtKF/9AGUOe8btI+CcYNoCBImoHwBtj1SoAn94kJCZj0b7UnQ== --e89a8f6434b6afc98804c84224b3 Content-Type: text/plain; charset=ISO-8859-1 Some thoughts on this: Uses: 1. Start-up / single-fire events 2. Multi-fire custom event types "menubutton", "searchbutton", "backbutton", "pause", "resume" 3. Hooking document.addEventListener(foo) Currently state: channel.js does 1 well, but does 2 except for the fired state behaviour, and 3 is done by cordova.js. Thoughts: - Channel does a good job at #1, although it could be simplified if that's all we need it for. - We would get truer (proper propagation) event behaviour if we just fired custom events on actual DOM via createEvent & dispatchEvent - Using DOM events is a bit harder to debug since it goes in & out of native. It's also slower for this reason. How to make Channel good at both 1 and 2: - Add a mode to make a channel as sticky or not - If Sticky, don't hold onto subscribers after initial fire (free up memory) - If not sticky, don't fire upon subscription I'm thinking that we don't need a dramatic change. On Mon, Aug 27, 2012 at 9:50 AM, Filip Maj wrote: > I think it's time for a review of this module and how it fits into > cordova-js. Spell out exactly what we need from it, and then find a > suitable replacement or do a rewrite. A few of the channels have specific > firing needs e.g. deviceready. I think we can get something much > smaller/simpler in there. > > If I remember correctly, I hacked this out of complete ui, a > Nitobi-written UI library from like.. 2007. Pretty sure it's Dave > Johnson's code too! It may have been too much for our purposes any ways. > > On 8/24/12 12:15 PM, "Andrew Grieve" wrote: > > >I like that idea. Channel already has an opts param in its ctor, so I'll > >just throw a boolean into it. > > > >channel.create('pause', { multi: true }); > > > >Created a bug for this: https://issues.apache.org/jira/browse/CB-1274 > > > > > > > > > >On Fri, Aug 24, 2012 at 1:46 PM, Gord Tanner wrote: > > > >> I know there was some talk on the mailing list awhile ago of replacing > >>the > >> channel module with something a little simpler. > >> > >> If we do want to patch this issue I would suggest having this done at > >> construction time. > >> > >> var deviceready = channel.create('deviceready', channel.types.once); > >> var pause = channel.create('pause', channel.types.refireable); > >> > >> (naming in example above is for discussion purposes only ;) ) > >> > >> On Fri, Aug 24, 2012 at 11:37 AM, Andrew Grieve >> >wrote: > >> > >> > I was looking through the channel code and noticed that the fired > >>state > >> is > >> > never assigned to false. This makes sense for channels like > >> onDeviceReady, > >> > when you'd want this to stay active. But... > >> > > >> > It's a bit strange for things like onPause and onResume. It means > >>that if > >> > the app has ever been paused or resumed, then every new listener going > >> > forward is going to fire upon subscription even though the current > >>state > >> is > >> > not paused/resumed. I tested this out locally, and it appears to be > >>true. > >> > So... > >> > > >> > How about we add a method called "fireOnce", which calls fire() and > >>then > >> > sets fired = false so that new subscribers will not be immediately > >> > triggered. > >> > > >> > >> > >> > >> -- > >> Gord Tanner > >> Senior Developer / Code Poet > >> tinyHippos Inc. > >> @tinyhippos > >> > > --e89a8f6434b6afc98804c84224b3--