Return-Path: X-Original-To: apmail-cordova-dev-archive@www.apache.org Delivered-To: apmail-cordova-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 86896178C2 for ; Tue, 9 Jun 2015 23:10:30 +0000 (UTC) Received: (qmail 22146 invoked by uid 500); 9 Jun 2015 23:10:30 -0000 Delivered-To: apmail-cordova-dev-archive@cordova.apache.org Received: (qmail 22125 invoked by uid 500); 9 Jun 2015 23:10:30 -0000 Mailing-List: contact dev-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list dev@cordova.apache.org Received: (qmail 22113 invoked by uid 99); 9 Jun 2015 23:10:29 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Jun 2015 23:10:29 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of brian.leroux@gmail.com designates 209.85.216.42 as permitted sender) Received: from [209.85.216.42] (HELO mail-vn0-f42.google.com) (209.85.216.42) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Jun 2015 23:08:16 +0000 Received: by vnbf190 with SMTP id f190so5216613vnb.0 for ; Tue, 09 Jun 2015 16:10:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:content-type; bh=fKeHQxmbbFsfbzV4HSlu2vGq9P94xprIaQOPFcqu/UM=; b=Ocu0UAdkSv8YJVNObrkBYVAf2u6hV7pa16vHWYaM1WG/L0jRiZ7E62njgc10I607lQ zNX0NtNBaqTvo/hDAbGx8FEcMKhVYEayz5wENTAzwPG/S4ihzLNuVTqP59lrL+xEkjQi 6lUA8Tci1m8BbubCpNlft9bIcELgIh4WyqVc2nKEpOUcGjjVGd1kuB9qTWgdERDZNHqT Ysj+XR5xzD6LOYItaY/e61kp6zWlrK+zrGS9HfE4udUwArmY/Mr5YtABt+5FDPVDMj/V ZW1n4dXe9x7bxGMZHgiBWfZ6KXRGoCFt7m18R4BcOaOpmaJ8RRQoZy/s7+hWujySBVTq pbGQ== MIME-Version: 1.0 X-Received: by 10.52.72.40 with SMTP id a8mr423384vdv.22.1433891403635; Tue, 09 Jun 2015 16:10:03 -0700 (PDT) Sender: brian.leroux@gmail.com Received: by 10.31.181.72 with HTTP; Tue, 9 Jun 2015 16:10:03 -0700 (PDT) In-Reply-To: References: Date: Tue, 9 Jun 2015 16:10:03 -0700 X-Google-Sender-Auth: wK5rgoj-p871Gfd8BjrvLAuouO4 Message-ID: Subject: Re: Sticky Channels From: Brian LeRoux To: "dev@cordova.apache.org" Content-Type: multipart/alternative; boundary=20cf307f360cc2a4d805181ddbe3 X-Virus-Checked: Checked by ClamAV on apache.org --20cf307f360cc2a4d805181ddbe3 Content-Type: text/plain; charset=UTF-8 big -1 on promises from me; they've only been a pain for us thus far (ask steve about the plugman debugging maybe when they're "native". maaaaybe. On Tue, Jun 9, 2015 at 7:27 AM, Ian Clelland wrote: > On Tue, Jun 9, 2015 at 10:19 AM, Andrew Grieve > wrote: > > > I think the only place sticky channels are used is for startup events > > (deviceready, nativeready, pluginsready, etc). I think you could probably > > change them to fire multiple times without breaking too much, but the > > semantics of that seem really strange to me (fire the most recent event, > or > > all events? upon registering, but only to the newly added listener(s)) > > > > They are not based on any standard, so it might be nice not to use them, > > and instead use standard events (e.g. cordova.fireWindowEvent). As long > as > > we promise not to fire them until after deviceready, apps should be able > to > > register listeners reliably. > > > > This was an area that I was hoping to leverage to use promises instead, > back when we were discussing baking those into cordova.js -- it would be a > major change from the existing way of doing things, but sticky channels are > closer in spirit to promises than they are to events, I think. > > It's very similar to the service worker `ready` attribute -- before the > worker is active, it returns a promise that asynchronously waits for > everything to be ready, and then fires. After the worker is already active, > the promise resolves immediately, just like deviceready does if you attach > a listener after Cordova has initialized. > > > > > > One other data point for this is that I dealt with the as-a-service vs. > > as-a-launch in > > https://github.com/MobileChromeApps/cordova-plugin-background-app. In > this > > model, I set a property before each resume / deviceready that can be > > queried to find out the app's state. Could possibly do similar for > intents > > (but would need an event as well since they can come at any time, not > just > > on start-up) > > > > On Fri, Jun 5, 2015 at 7:18 PM, Jesse wrote: > > > > > I have been looking into unifying launchParameters across devices so > that > > > all cordova apps can get some context of how they were > > launched/activated. > > > This includes everything from a url/protocol launch in another app, to > a > > > touch on a notification (toast,local,push,... ) > > > > > > My intent was to add a channel for this, however I have had some issues > > > with channels + stickiness. > > > > > > I wanted a channel that would call new subscribers immediately if it > had > > > already fired. In our channel implementation this is what we call a > > sticky > > > channel. However, this particular channel may fire more than once, ie. > > we > > > could be activated multiple times while running, or receive multiple > > > notifications. > > > The current implementation for sticky will only ever call subscribers > > once, > > > and if I call fire() more than once, it actually removes it's > > subscribers. > > > [1] So I cannot use this as is for my needs. > > > > > > So my questions are : > > > 1. Why is like this? Is there some standard or expectation that this is > > > based on? > > > 2. Can I change it? What would be the impact of changing the behavior > to > > > have a sticky channel fire more than once, and keep its list of > > > subscribers? > > > 3. Are there historical reasons that things are the way they are? The > > code > > > has been through several major moves since it was written, so it is > > > difficult to pin the original commit (Fil, Andrew? some merged pr?) If > > > there are historical reasons, are they still relevant? > > > > > > Please keep in mind too that I am not asking for the solution to my > > > specific task, I can work around anything ... I am asking solely about > > the > > > current channel-sticky implementation and it we should change it. > > > > > > Cheers, > > > Jesse > > > > > > > > > The current implementation > > > [1] > > > > > > https://github.com/apache/cordova-js/blob/master/src/common/channel.js#L216 > > > > > > > > > @purplecabbage > > > risingj.com > > > > > > --20cf307f360cc2a4d805181ddbe3--