On Thu, Mar 14, 2013 at 1:54 PM, Alex Russell <slightlyoff@google.com>wrote:
> On Wednesday, March 6, 2013, Tobie Langel wrote:
>
>> On Wednesday, March 6, 2013 at 5:51 PM, Jarred Nicholls wrote:
>> > This is an entirely different conversation though. I don't know the
>> answer to why sync interfaces are there and expected, except that some
>> would argue that it makes the code easier to read/write for some devs.
>> Since this is mirrored throughout other platform APIs, I wouldn't count
>> this as a fault in IDB specifically.
>>
>> Sync APIs are useful to do I/O inside of a Worker.
>>
>
> I don't understand why that's true. Workers have a message-oriented API
> that's inherently async. They can get back to their caller "whenevs".
> What's the motivator for needing this?
>
Being able to write synchronous code is one of the basic uses for Workers
in the first place. Synchronously creating streams is useful in the same
way that other synchronous APIs are useful, such as FileReaderSync.
That doesn't necessarily mean having a synchronous API for a complex
interface like this is the ideal approach (there are other ways to do it),
but that's the end goal.
(FYI, the messaging in Workers isn't inherently async; it just happens to
only have an async interface. There's been discussion about adding a
synchronous interface to messaging.)
--
Glenn Maynard