Newsgroups: mozilla.dev.webapi
From: Jonas Sicking <jo...@sicking.cc>
Date: Mon, 12 Nov 2012 16:18:31 -0800
Local: Mon, Nov 12 2012 7:18 pm
Subject: Re: Feedback on the SMS API
On Fri, Nov 9, 2012 at 1:58 AM, David Bruant <bruan...@gmail.com> wrote:
I'm quite serious. The web needs a standardized promise.
> Le 09/11/2012 09:03, Jonas Sicking a écrit : >> On Tue, Nov 6, 2012 at 4:32 AM, David Bruant <bruan...@gmail.com> wrote:
>>> # The SmsRequest object smells like a promise. It does very very badly.
>> I'd love to have a standardized promise API which we could use. If
>> https://twitter.com/SickingJ/status/202152629743255552
> :-D
>>> # The send method takes a string as first argument. String rarely are a
Actually, in SMS it is. SMS doesn't have the ability to send the same
>>> good >>> thing to represent objects. Especially phone numbers. >>> An anecdote, In France, cell phone numbers used to start with "06". We >>> ran >>> out, so it's been decided that cell phone numbers would also start with >>> "07". A friend of mine shared with me that it took 6 months of >>> development >>> to FranceTelecom (historical and major Telco operator) to prepare to this >>> change, mostly because they used strings to represent phone numbers. >>> Especially with cell phones shipping all across the globe, I really think >>> there is value in having an object representation of phone numbers, very >>> much like we do (sort of) with URLs. >> So far no-one has come up with a standard for a parsed phone number.
>> If you figure out a way to solve this, I'm all ears.
>>> # I hardly see the need of the second send method that accepts an array.
>>> It would probably simplify the implementation of send on your side.
>> I tend to agree.
> Jose's made a good point though, that when you send one message to several
message to multiple people. When you are entering multiple recipients in an SMS app it actually turns around and sends a set of separate messages. This is why this function returns an array of SMSRequests, since the messages will be sent independently and thus can fail independently. MMS however allows sending a single message to multiple people. But
>>> # "Should use opaque objects as message-identifiers rather than longs?"
Being able to store identifiers in local databases is a requirement in
>>> => Yes, and the SmsMessage instance itself is this object. >>> From the object capability perspective, it would be better to be able to >>> delete only messages you have access to. >>> Actually, I would rather prefer SmsMessage.prototype.delete than >>> SmsManager.delete, this way, it's clear you can only delete messages you >>> have access to. >> This would make it impossible to store a message identifier in
> I agree message ids should be kept in the SmsMessage API and as a retrieval
my opinion. Otherwise it gets very hard to cache any data locally in the app and cross-reference to the SMS database. >>> # getMessages and SmsFilter
The difference between using an index which only contains the 10
>>> A more generic way would be to accept a function as first argument. This >>> function is passed a SmsMessage and returns true or false depending on >>> whether we want to keep the message or not akin to >>> Array.prototype.filter. >>> It would be interesting to provide some convenience with SmsFilters: >>> var filter = new SmsFilter({delivery: "received"});
>>> Basically, SmsFilter generates a function which [[Call]] does the right
>> The performance of that would be really bad since we couldn't use an
> How bad would it really be? What is the performance benefit (in time, not
messages that you have exchanged with a specific person, vs. using a filter which is required to scan the 10000 messages that you have in the full database is about three orders of magnitude :) So yes, it makes a big difference.
We recently had to rewrite a part of the SMS app in order to avoid a
> Also, I forgot, but in the getMessages method, both arguments should be
I believe that's already the case in the implementation.
> optional in my opinion. Reverse defaulting to false and filter to... > undefined? and no filter would return a promise (hopefully soon) to all > messages. / Jonas
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||