You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by Brian LeRoux <b...@brian.io> on 2013/01/28 19:34:08 UTC

best practice plugin authoring guidelines / window.plugins hate

The community is starting to put plugins in their own repos (good). I
noticed this one today:

https://github.com/vstirbu/InstagramPlugin

(Awesome.)

But I can't stand window.plugins any longer. I think this might be a
hangover from the existing plugin space but not totally sure---is
there a good reason to have the plugins global "namespace" anymore?

Re: best practice plugin authoring guidelines / window.plugins hate

Posted by Andrew Grieve <ag...@chromium.org>.
One consideration is that right now our module names are based on file
paths. e.g. "cordova/plugin/FileTransfer" maps to
lib/common/plugin/FileTransfer.js. If end-users reference the module via
cordova.require, then any time we move a file, we'd need to add extra logic
to ensure the old path still works... maybe module.defineAlias()?

Having a mapping of module -> JS symbol gives us a bit more flexibility,
but also requires a bit of time during page-load to register all of the
symbols.



On Mon, Jan 28, 2013 at 2:35 PM, Jesse <pu...@gmail.com> wrote:

> The require step is overkill in this case IMHO, although exec 'should'
> likely be :
> var exec = cordova.require('cordova/exec');
>
>
> https://github.com/purplecabbage/InstagramPlugin/blob/master/www/CDVInstagramPlugin.js
>
> Pull request sent
>
> Instagram.isInstalled(callback);
> Instagram.share(canvasId,callback);
>
>
>
>
>
> On Mon, Jan 28, 2013 at 11:27 AM, Don Coleman <do...@gmail.com>
> wrote:
>
> > +1
> >
> >
> >
> > On Mon, Jan 28, 2013 at 2:23 PM, Brian LeRoux <b...@brian.io> wrote:
> >
> > > ah sorry that is what I meant actually----tho it does beg how
> > > cordova.require and various other requires might work
> > >
> > > (I think Pat brought this up last year.)
> > >
> > > On Mon, Jan 28, 2013 at 11:15 AM, Filip Maj <fi...@adobe.com> wrote:
> > > > Hmm, how does this fit in with cordova.require ?
> > > >
> > > > On 1/28/13 11:11 AM, "Brian LeRoux" <b...@brian.io> wrote:
> > > >
> > > >>I'm thinking we encourage:
> > > >>
> > > >>var insta = require('instagram')
> > > >>insta.share( ... )
> > > >>
> > > >>
> > > >>
> > > >>On Mon, Jan 28, 2013 at 12:51 PM, Jesse <pu...@gmail.com>
> > wrote:
> > > >>> No reason to exist there, other than that is the way it used to be.
> > > >>> I would rather just see :
> > > >>>
> > > >>> var myRef = Instagram.install();
> > > >>> myRef.share( ... )
> > > >>>
> > > >>> I'll fork it.
> > > >>>
> > > >>> Also, I think we need to educate people on the use of
> > > >>>objects&&prototypes,
> > > >>> by example.
> > > >>> We too have multiple places where we define a prototype object of
> > which
> > > >>> there will only evar be one ... off-topic sorry ...
> > > >>>
> > > >>>
> > > >>>
> > > >>>
> > > >>> On Mon, Jan 28, 2013 at 10:40 AM, Filip Maj <fi...@adobe.com> wrote:
> > > >>>
> > > >>>> Don't think so. Should be up to the user. That said Cordova should
> > > >>>>provide
> > > >>>> a registration mechanism to enable collision detection (I think
> > Andrew
> > > >>>> Grieve has something like this in his symbol mapping branch in
> > > >>>>cordova-js).
> > > >>>>
> > > >>>> On 1/28/13 10:34 AM, "Brian LeRoux" <b...@brian.io> wrote:
> > > >>>>
> > > >>>> >The community is starting to put plugins in their own repos
> > (good). I
> > > >>>> >noticed this one today:
> > > >>>> >
> > > >>>> >https://github.com/vstirbu/InstagramPlugin
> > > >>>> >
> > > >>>> >(Awesome.)
> > > >>>> >
> > > >>>> >But I can't stand window.plugins any longer. I think this might
> be
> > a
> > > >>>> >hangover from the existing plugin space but not totally sure---is
> > > >>>> >there a good reason to have the plugins global "namespace"
> anymore?
> > > >>>>
> > > >>>>
> > > >>>
> > > >>>
> > > >>> --
> > > >>> @purplecabbage
> > > >>> risingj.com
> > > >
> > >
> >
>
>
>
> --
> @purplecabbage
> risingj.com
>

Re: best practice plugin authoring guidelines / window.plugins hate

Posted by Jesse <pu...@gmail.com>.
The require step is overkill in this case IMHO, although exec 'should'
likely be :
var exec = cordova.require('cordova/exec');

https://github.com/purplecabbage/InstagramPlugin/blob/master/www/CDVInstagramPlugin.js

Pull request sent

Instagram.isInstalled(callback);
Instagram.share(canvasId,callback);





On Mon, Jan 28, 2013 at 11:27 AM, Don Coleman <do...@gmail.com> wrote:

> +1
>
>
>
> On Mon, Jan 28, 2013 at 2:23 PM, Brian LeRoux <b...@brian.io> wrote:
>
> > ah sorry that is what I meant actually----tho it does beg how
> > cordova.require and various other requires might work
> >
> > (I think Pat brought this up last year.)
> >
> > On Mon, Jan 28, 2013 at 11:15 AM, Filip Maj <fi...@adobe.com> wrote:
> > > Hmm, how does this fit in with cordova.require ?
> > >
> > > On 1/28/13 11:11 AM, "Brian LeRoux" <b...@brian.io> wrote:
> > >
> > >>I'm thinking we encourage:
> > >>
> > >>var insta = require('instagram')
> > >>insta.share( ... )
> > >>
> > >>
> > >>
> > >>On Mon, Jan 28, 2013 at 12:51 PM, Jesse <pu...@gmail.com>
> wrote:
> > >>> No reason to exist there, other than that is the way it used to be.
> > >>> I would rather just see :
> > >>>
> > >>> var myRef = Instagram.install();
> > >>> myRef.share( ... )
> > >>>
> > >>> I'll fork it.
> > >>>
> > >>> Also, I think we need to educate people on the use of
> > >>>objects&&prototypes,
> > >>> by example.
> > >>> We too have multiple places where we define a prototype object of
> which
> > >>> there will only evar be one ... off-topic sorry ...
> > >>>
> > >>>
> > >>>
> > >>>
> > >>> On Mon, Jan 28, 2013 at 10:40 AM, Filip Maj <fi...@adobe.com> wrote:
> > >>>
> > >>>> Don't think so. Should be up to the user. That said Cordova should
> > >>>>provide
> > >>>> a registration mechanism to enable collision detection (I think
> Andrew
> > >>>> Grieve has something like this in his symbol mapping branch in
> > >>>>cordova-js).
> > >>>>
> > >>>> On 1/28/13 10:34 AM, "Brian LeRoux" <b...@brian.io> wrote:
> > >>>>
> > >>>> >The community is starting to put plugins in their own repos
> (good). I
> > >>>> >noticed this one today:
> > >>>> >
> > >>>> >https://github.com/vstirbu/InstagramPlugin
> > >>>> >
> > >>>> >(Awesome.)
> > >>>> >
> > >>>> >But I can't stand window.plugins any longer. I think this might be
> a
> > >>>> >hangover from the existing plugin space but not totally sure---is
> > >>>> >there a good reason to have the plugins global "namespace" anymore?
> > >>>>
> > >>>>
> > >>>
> > >>>
> > >>> --
> > >>> @purplecabbage
> > >>> risingj.com
> > >
> >
>



-- 
@purplecabbage
risingj.com

Re: best practice plugin authoring guidelines / window.plugins hate

Posted by Don Coleman <do...@gmail.com>.
+1



On Mon, Jan 28, 2013 at 2:23 PM, Brian LeRoux <b...@brian.io> wrote:

> ah sorry that is what I meant actually----tho it does beg how
> cordova.require and various other requires might work
>
> (I think Pat brought this up last year.)
>
> On Mon, Jan 28, 2013 at 11:15 AM, Filip Maj <fi...@adobe.com> wrote:
> > Hmm, how does this fit in with cordova.require ?
> >
> > On 1/28/13 11:11 AM, "Brian LeRoux" <b...@brian.io> wrote:
> >
> >>I'm thinking we encourage:
> >>
> >>var insta = require('instagram')
> >>insta.share( ... )
> >>
> >>
> >>
> >>On Mon, Jan 28, 2013 at 12:51 PM, Jesse <pu...@gmail.com> wrote:
> >>> No reason to exist there, other than that is the way it used to be.
> >>> I would rather just see :
> >>>
> >>> var myRef = Instagram.install();
> >>> myRef.share( ... )
> >>>
> >>> I'll fork it.
> >>>
> >>> Also, I think we need to educate people on the use of
> >>>objects&&prototypes,
> >>> by example.
> >>> We too have multiple places where we define a prototype object of which
> >>> there will only evar be one ... off-topic sorry ...
> >>>
> >>>
> >>>
> >>>
> >>> On Mon, Jan 28, 2013 at 10:40 AM, Filip Maj <fi...@adobe.com> wrote:
> >>>
> >>>> Don't think so. Should be up to the user. That said Cordova should
> >>>>provide
> >>>> a registration mechanism to enable collision detection (I think Andrew
> >>>> Grieve has something like this in his symbol mapping branch in
> >>>>cordova-js).
> >>>>
> >>>> On 1/28/13 10:34 AM, "Brian LeRoux" <b...@brian.io> wrote:
> >>>>
> >>>> >The community is starting to put plugins in their own repos (good). I
> >>>> >noticed this one today:
> >>>> >
> >>>> >https://github.com/vstirbu/InstagramPlugin
> >>>> >
> >>>> >(Awesome.)
> >>>> >
> >>>> >But I can't stand window.plugins any longer. I think this might be a
> >>>> >hangover from the existing plugin space but not totally sure---is
> >>>> >there a good reason to have the plugins global "namespace" anymore?
> >>>>
> >>>>
> >>>
> >>>
> >>> --
> >>> @purplecabbage
> >>> risingj.com
> >
>

Re: best practice plugin authoring guidelines / window.plugins hate

Posted by Filip Maj <fi...@adobe.com>.
Yeh Pat brought it up almost a year ago!
https://issues.apache.org/jira/browse/CB-341

Stay on target.. Stay on taaaarget..

On 1/28/13 11:23 AM, "Brian LeRoux" <b...@brian.io> wrote:

>ah sorry that is what I meant actually----tho it does beg how
>cordova.require and various other requires might work
>
>(I think Pat brought this up last year.)
>
>On Mon, Jan 28, 2013 at 11:15 AM, Filip Maj <fi...@adobe.com> wrote:
>> Hmm, how does this fit in with cordova.require ?
>>
>> On 1/28/13 11:11 AM, "Brian LeRoux" <b...@brian.io> wrote:
>>
>>>I'm thinking we encourage:
>>>
>>>var insta = require('instagram')
>>>insta.share( ... )
>>>
>>>
>>>
>>>On Mon, Jan 28, 2013 at 12:51 PM, Jesse <pu...@gmail.com> wrote:
>>>> No reason to exist there, other than that is the way it used to be.
>>>> I would rather just see :
>>>>
>>>> var myRef = Instagram.install();
>>>> myRef.share( ... )
>>>>
>>>> I'll fork it.
>>>>
>>>> Also, I think we need to educate people on the use of
>>>>objects&&prototypes,
>>>> by example.
>>>> We too have multiple places where we define a prototype object of
>>>>which
>>>> there will only evar be one ... off-topic sorry ...
>>>>
>>>>
>>>>
>>>>
>>>> On Mon, Jan 28, 2013 at 10:40 AM, Filip Maj <fi...@adobe.com> wrote:
>>>>
>>>>> Don't think so. Should be up to the user. That said Cordova should
>>>>>provide
>>>>> a registration mechanism to enable collision detection (I think
>>>>>Andrew
>>>>> Grieve has something like this in his symbol mapping branch in
>>>>>cordova-js).
>>>>>
>>>>> On 1/28/13 10:34 AM, "Brian LeRoux" <b...@brian.io> wrote:
>>>>>
>>>>> >The community is starting to put plugins in their own repos (good).
>>>>>I
>>>>> >noticed this one today:
>>>>> >
>>>>> >https://github.com/vstirbu/InstagramPlugin
>>>>> >
>>>>> >(Awesome.)
>>>>> >
>>>>> >But I can't stand window.plugins any longer. I think this might be a
>>>>> >hangover from the existing plugin space but not totally sure---is
>>>>> >there a good reason to have the plugins global "namespace" anymore?
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> @purplecabbage
>>>> risingj.com
>>


Re: best practice plugin authoring guidelines / window.plugins hate

Posted by Brian LeRoux <b...@brian.io>.
ah sorry that is what I meant actually----tho it does beg how
cordova.require and various other requires might work

(I think Pat brought this up last year.)

On Mon, Jan 28, 2013 at 11:15 AM, Filip Maj <fi...@adobe.com> wrote:
> Hmm, how does this fit in with cordova.require ?
>
> On 1/28/13 11:11 AM, "Brian LeRoux" <b...@brian.io> wrote:
>
>>I'm thinking we encourage:
>>
>>var insta = require('instagram')
>>insta.share( ... )
>>
>>
>>
>>On Mon, Jan 28, 2013 at 12:51 PM, Jesse <pu...@gmail.com> wrote:
>>> No reason to exist there, other than that is the way it used to be.
>>> I would rather just see :
>>>
>>> var myRef = Instagram.install();
>>> myRef.share( ... )
>>>
>>> I'll fork it.
>>>
>>> Also, I think we need to educate people on the use of
>>>objects&&prototypes,
>>> by example.
>>> We too have multiple places where we define a prototype object of which
>>> there will only evar be one ... off-topic sorry ...
>>>
>>>
>>>
>>>
>>> On Mon, Jan 28, 2013 at 10:40 AM, Filip Maj <fi...@adobe.com> wrote:
>>>
>>>> Don't think so. Should be up to the user. That said Cordova should
>>>>provide
>>>> a registration mechanism to enable collision detection (I think Andrew
>>>> Grieve has something like this in his symbol mapping branch in
>>>>cordova-js).
>>>>
>>>> On 1/28/13 10:34 AM, "Brian LeRoux" <b...@brian.io> wrote:
>>>>
>>>> >The community is starting to put plugins in their own repos (good). I
>>>> >noticed this one today:
>>>> >
>>>> >https://github.com/vstirbu/InstagramPlugin
>>>> >
>>>> >(Awesome.)
>>>> >
>>>> >But I can't stand window.plugins any longer. I think this might be a
>>>> >hangover from the existing plugin space but not totally sure---is
>>>> >there a good reason to have the plugins global "namespace" anymore?
>>>>
>>>>
>>>
>>>
>>> --
>>> @purplecabbage
>>> risingj.com
>

Re: best practice plugin authoring guidelines / window.plugins hate

Posted by Filip Maj <fi...@adobe.com>.
Hmm, how does this fit in with cordova.require ?

On 1/28/13 11:11 AM, "Brian LeRoux" <b...@brian.io> wrote:

>I'm thinking we encourage:
>
>var insta = require('instagram')
>insta.share( ... )
>
>
>
>On Mon, Jan 28, 2013 at 12:51 PM, Jesse <pu...@gmail.com> wrote:
>> No reason to exist there, other than that is the way it used to be.
>> I would rather just see :
>>
>> var myRef = Instagram.install();
>> myRef.share( ... )
>>
>> I'll fork it.
>>
>> Also, I think we need to educate people on the use of
>>objects&&prototypes,
>> by example.
>> We too have multiple places where we define a prototype object of which
>> there will only evar be one ... off-topic sorry ...
>>
>>
>>
>>
>> On Mon, Jan 28, 2013 at 10:40 AM, Filip Maj <fi...@adobe.com> wrote:
>>
>>> Don't think so. Should be up to the user. That said Cordova should
>>>provide
>>> a registration mechanism to enable collision detection (I think Andrew
>>> Grieve has something like this in his symbol mapping branch in
>>>cordova-js).
>>>
>>> On 1/28/13 10:34 AM, "Brian LeRoux" <b...@brian.io> wrote:
>>>
>>> >The community is starting to put plugins in their own repos (good). I
>>> >noticed this one today:
>>> >
>>> >https://github.com/vstirbu/InstagramPlugin
>>> >
>>> >(Awesome.)
>>> >
>>> >But I can't stand window.plugins any longer. I think this might be a
>>> >hangover from the existing plugin space but not totally sure---is
>>> >there a good reason to have the plugins global "namespace" anymore?
>>>
>>>
>>
>>
>> --
>> @purplecabbage
>> risingj.com


Re: best practice plugin authoring guidelines / window.plugins hate

Posted by Brian LeRoux <b...@brian.io>.
I'm thinking we encourage:

var insta = require('instagram')
insta.share( ... )



On Mon, Jan 28, 2013 at 12:51 PM, Jesse <pu...@gmail.com> wrote:
> No reason to exist there, other than that is the way it used to be.
> I would rather just see :
>
> var myRef = Instagram.install();
> myRef.share( ... )
>
> I'll fork it.
>
> Also, I think we need to educate people on the use of objects&&prototypes,
> by example.
> We too have multiple places where we define a prototype object of which
> there will only evar be one ... off-topic sorry ...
>
>
>
>
> On Mon, Jan 28, 2013 at 10:40 AM, Filip Maj <fi...@adobe.com> wrote:
>
>> Don't think so. Should be up to the user. That said Cordova should provide
>> a registration mechanism to enable collision detection (I think Andrew
>> Grieve has something like this in his symbol mapping branch in cordova-js).
>>
>> On 1/28/13 10:34 AM, "Brian LeRoux" <b...@brian.io> wrote:
>>
>> >The community is starting to put plugins in their own repos (good). I
>> >noticed this one today:
>> >
>> >https://github.com/vstirbu/InstagramPlugin
>> >
>> >(Awesome.)
>> >
>> >But I can't stand window.plugins any longer. I think this might be a
>> >hangover from the existing plugin space but not totally sure---is
>> >there a good reason to have the plugins global "namespace" anymore?
>>
>>
>
>
> --
> @purplecabbage
> risingj.com

Re: best practice plugin authoring guidelines / window.plugins hate

Posted by Jesse <pu...@gmail.com>.
No reason to exist there, other than that is the way it used to be.
I would rather just see :

var myRef = Instagram.install();
myRef.share( ... )

I'll fork it.

Also, I think we need to educate people on the use of objects&&prototypes,
by example.
We too have multiple places where we define a prototype object of which
there will only evar be one ... off-topic sorry ...




On Mon, Jan 28, 2013 at 10:40 AM, Filip Maj <fi...@adobe.com> wrote:

> Don't think so. Should be up to the user. That said Cordova should provide
> a registration mechanism to enable collision detection (I think Andrew
> Grieve has something like this in his symbol mapping branch in cordova-js).
>
> On 1/28/13 10:34 AM, "Brian LeRoux" <b...@brian.io> wrote:
>
> >The community is starting to put plugins in their own repos (good). I
> >noticed this one today:
> >
> >https://github.com/vstirbu/InstagramPlugin
> >
> >(Awesome.)
> >
> >But I can't stand window.plugins any longer. I think this might be a
> >hangover from the existing plugin space but not totally sure---is
> >there a good reason to have the plugins global "namespace" anymore?
>
>


-- 
@purplecabbage
risingj.com

Re: best practice plugin authoring guidelines / window.plugins hate

Posted by Filip Maj <fi...@adobe.com>.
Don't think so. Should be up to the user. That said Cordova should provide
a registration mechanism to enable collision detection (I think Andrew
Grieve has something like this in his symbol mapping branch in cordova-js).

On 1/28/13 10:34 AM, "Brian LeRoux" <b...@brian.io> wrote:

>The community is starting to put plugins in their own repos (good). I
>noticed this one today:
>
>https://github.com/vstirbu/InstagramPlugin
>
>(Awesome.)
>
>But I can't stand window.plugins any longer. I think this might be a
>hangover from the existing plugin space but not totally sure---is
>there a good reason to have the plugins global "namespace" anymore?