Agreed.
OK, any strong objections (with a good reason) for making the syntax
form below our standard?
Promise p = someObject.someMethod(<parameters>);
I do have a related thought. How closely are we trying to hew to
JavaScript syntax in the syntax box? I wonder if we would want to
consider this:
Promise<ReturnType> p = someObject.someMethod(<parameters>);
This would let the syntax box indicate what type is delivered to the
Promise's fulfillment handler; in this case, the fulfillment handler is
passed an object of type ReturnType.
This would be a way to get that information up into the syntax box. Once
I hear discussion on that idea, I'll document the results of this
discussion in our contributor guide.
jperrier wrote:
> I also think that having simply the Promise p = foo() (or similar in
> the syntax, but an example with .then() (or more) is the better of
> doing.
> (I think we should not debate the order of example/syntax now, as this
> should be done for all the properties/methods at some point)
> I would agree that examples should go right ahead and use the
> foo().then syntax, but I definitely think the syntax box needs to
> simply be Promise p = foo(). No point conflating the interface being
> documented and promises themselves, IMO.
>
>
> Sebastian Zartner <mailto:
sebastia...@gmail.com>
> July 8, 2016 at 7:30 AM
> I agree with Jérémie, but I'd not only put this into two steps but
> into two separate blocks. The syntax box should only contain the bare
> syntax. Usage examples should be added below.
>
> Chris Mills <mailto:
cmi...@mozilla.com>
> July 8, 2016 at 5:21 AM
> Jeremie Patonnier <mailto:
jeremie....@gmail.com>
> July 8, 2016 at 5:19 AM
> I'm with sheppy here :)
>
> Even if examples should demonstrate how to use the promise, I would
> tend to break it down in two steps to make things obvious that the
> initial method return an object (a Promise) then how this object is used.
>
> Doing all in one row is, IMO, misleading for beginner as it's not
> always straight forward how chaining is working in JS. Using promise
> is more than "then" and I think it's good to remind that manipulating
> promise is a whole world in itslef just by breaking down thing in two
> obvious step.
>
>
>
>
> --
> Jeremie
> .............................
> Web :
http://jeremie.patonnier.net <
http://jeremie.patonnier.net/>
> Twitter : @JeremiePat <
http://twitter.com/JeremiePat>
> Chris Mills <mailto:
cmi...@mozilla.com>
> July 8, 2016 at 4:28 AM
> I am firmly in the other camp ;-)
>
> I think the
>
> Interface.method().then(function() {
> //stuff
> })
>
> Is more common, and much more intuitive to see how you’d actually use
> the method in the wild, so better for beginners/intermediates.
> Advanced people can probably work the other usage model out for
> themselves.
>
> I can see your point about purity, and wanting to get rid of as much
> cruft as possible, but I think it is a balance. Too much stripping
> down starts to remove useful context, making it harder to work out how
> to actually use it.
>
> Chris Mills
> Senior tech writer || Mozilla
>
developer.mozilla.org || MDN
>
cmi...@mozilla.com || @chrisdavidmills
>
>