W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2013

Re: [futures] Persistent/Repeated Future that doesn't resolve

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Sat, 13 Apr 2013 12:28:38 -0700
Message-ID: <CAAWBYDC1cJvzUesxEsMB-KppCuYs7Jk7qdoUduH9cRHL21SQow@mail.gmail.com>
To: "www-dom@w3.org" <www-dom@w3.org>
On Thu, Apr 11, 2013 at 4:23 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
> Basically, what I need is something like a ProgressFuture (after the
> "immediately ping with most recent value" change from my previous
> email), but which never completes.  That way I could just register a
> callback, get called in the next tick with the current value, and then
> called again every time the value is updated, forever.

After some thinking, I realized that this should be solveable using
the existing Object.observe() proposal, which lets you register a
callback for observing changes of a value.

Creating a Stream abstraction might still be a good idea so that it
can be used as a *return value* for Object.observe() (rather than it
taking a callback directly), and Object.observe() itself could
probably be augmented with an ability to filter for changes to a
single property only.

That way, I could address my use-case by just exposing a "loadStatus"
attribute which alternates between "loading" and "loaded", and then
authors could use "Object.observe(document.fonts,
'loadStatus').listen(cb)" to listen for changes. This isn't overly
verbose, considering the value of the use-case, and generalizes to
every attribute without effort.

So, let's still design a Stream abstraction, but I can go ahead and do
my own API design without worrying about it for now.

~TJ
Received on Saturday, 13 April 2013 19:29:24 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:20 UTC