Re: CFC: Attaching 'extras' to the intent payload

+1 to an extra optional additional parameter.

On Mon, Mar 5, 2012 at 10:22 PM, timeless <timeless@gmail.com> wrote:

> You can use "optional dict extras" for A to address Rachel's concern...
>
> With that, I favor A
>
> On 3/5/12, Rachel Blum <groby@google.com> wrote:
> > Initial reaction is C) It is almost identical to A), except that intents
> > without extras don't need an extra parameter.
> >
> > I'm not to fond of B), since it replicates a dictionary-like API on a
> > non-dictionary object.
> >
> > Rachel
> > On Mar 5, 2012 1:54 PM, "James Hawkins" <jhawkins@google.com> wrote:
> >
> >> TL;DR - We need a method to set extra data on the intent payload.
>  Ideas?
> >>
> >> For several use cases, extra data which augments the payload needs to
> >> be passed either to or from the client.  For example a picker which
> >> returns files may want to pass along the filename of the picked file.
> >>
> >> There are several ways to augment the API to allow providing extras.
> >> Let's go over constraints first:
> >> * Must be allowed to pass several extras.
> >> * It follows from above that the extras must be named.
> >>   - We could impose ordering in an array as a solution, but that is
> >> extremely fragile!
> >>
> >> >From the constraints it's clear we need a dictionary for extras.
> >> Android Intents agrees and uses a 'Bundle', which is "a mapping from
> >> String values to various Parcelable types."  Different parlance, same
> >> concept.
> >>
> >> Android
> >> ======
> >>
> >> >From the Android Intents spec:
> >>
> >>   Intent putExtra(String name, [type] value);
> >>
> >> putExtra is overloaded for each native [type], e.g., double, int,
> >> Bundle, Parcelable, etc.
> >>
> >>
> >> Possible Solutions
> >> ==============
> >>
> >> A) Add an |extras| parameter to the Intent constructor:
> >>
> >> Currently:
> >>  [Constructor(in string action, in string type, in any data) raises
> >> DOMException]
> >>
> >> Modified:
> >>  [Constructor(in string action, in string type, in any data, in
> >> Dictionary extras) raises DOMException]
> >>
> >> e.g.,
> >>
> >>  var dict = {filename: 'image.png', size: 20000};
> >>  var intent = new Intent('http://webintents.org/save', 'image/png',
> >> imageData, dict);
> >>
> >>
> >> B) Add a method to set an extra on Intent:
> >>
> >>  interface Intent {
> >>    ...
> >>    void setExtra(DOMString name, any value);
> >>  }
> >>
> >> e.g.,
> >>
> >>  var intent = new Intent('http://webintents.org/save', 'image/png',
> >> imageData);
> >>  intent.setExtra('filename', 'image.png');
> >>  intent.setExtra('size', 20000);
> >>
> >>
> >> C) Add a method to set the entire |extras| dictionary on Intent:
> >>
> >>  interface Intent {
> >>    ...
> >>    void setExtras(Dictionary extras);
> >>  }
> >>
> >> e.g.,
> >>
> >>  var intent = new Intent('http://webintents.org/save', 'image/png',
> >> imageData);
> >>
> >>  var dict = {filename: 'image.png', size: 20000};
> >>  intent.setExtras(dict);
> >>
> >>
> >> What are your thoughts, preferences, anecdotal evidence?  I'd love to
> >> hear your feedback on the issue.  Any other methods than those I
> >> listed?
> >>
> >> Thanks,
> >> James
> >>
> >>
> >
>
> --
> Sent from my mobile device
>
>

Received on Monday, 5 March 2012 23:44:32 UTC