summarise the summaries

132 views
Skip to first unread message

Andrius Aučinas

unread,
Mar 6, 2013, 12:06:18 PM3/6/13
to mutation-sum...@googlegroups.com
Really great job with the library!

I've been wondering though if there is a reasonable way at the moment to summarise the mutation summaries. Since the mutation observer callback is basically fired at will, so is mutation summary callback. Is there a way to have some more control over when it happens? For example, I might want to only collect them when some network-based event happens.

An example to look at is takeSummaries(), but it is only useful to get the observer records that are still in the queue.

Buffering all summaries as they are reported is one option, however it loses the main point against just using Mutation Observers (a log of stuff that has happened in the order it happened vs. a set of things that definitely has happened). One idea I had was to merge summaries based on the NodeMap ID's, but it seems like it should definitely break in some corner-cases. Although I will need a deeper look into it to verify. Another option is to stick with Mutation Records until I want to get the summaries and then feed them into createSummaries(), but this is not very elegant either...

So basically, is there a way to use Mutation Summary to report "a set of things that definitely has happened" between two arbitrary (more or less) points in time?

Regards,
Andrius

Rafael Weinstein

unread,
Mar 6, 2013, 12:54:38 PM3/6/13
to mutation-sum...@googlegroups.com
I think maybe I don't understand your request. What you describe here
is exactly what takeSummaries() does:

It returns the set of things that has definitely changed since the
last time changes were delivered (either via the callback of via
takeSummaries()) and now.

If this isn't what you need, perhaps you can make your use case a bit
more concrete with an code sample.

>
> Regards,
> Andrius
>
> --
> You received this message because you are subscribed to the Google Groups
> "mutation-summary-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mutation-summary-d...@googlegroups.com.
> To post to this group, send email to
> mutation-sum...@googlegroups.com.
> Visit this group at
> http://groups.google.com/group/mutation-summary-discuss?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Andrius Aučinas

unread,
Mar 6, 2013, 1:45:47 PM3/6/13
to mutation-sum...@googlegroups.com
takeSummaries() does the right kind of thing, but only for the "leftover" mutations (var mutations = observer.takeRecords(); var summaries = createSummaries(mutations);). But there is no control over what is left in the buffer, as that is controller by the MutationObserver.

Not quite what I want to do, but if this worked, I would be able to do anything:

window.setInterval(function(){
  var summaries = mutationSummary.takeSummaries();
  socket.send(summaries);
},5000);

Which basically would take mutation summaries every 5 seconds and send them "somewhere". Replace the time interval with an arbitrary number or base the whole thing on an arbitrary event and you'll see what I need.

The actual purpose of this is dealing with intermittent connectivity - you don't really want to be buffering summaries until the next time network becomes available, but you still want to be able to get the changes on the other side without restarting from scratch.


>
> Regards,
> Andrius
>
> --
> You received this message because you are subscribed to the Google Groups
> "mutation-summary-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mutation-summary-discuss+unsub...@googlegroups.com.

Rafael Weinstein

unread,
Mar 6, 2013, 4:38:12 PM3/6/13
to mutation-sum...@googlegroups.com
I could add an option like "onlyTakeSummaries" which would cause it
never to deliver pre-emptively, but queue all changes until you "pull"
them with takeSummaries().

That way you can have a setTimeout poll interval, and you'll only ever
process changes since the last poll.

Would that solve your use case?

On Wed, Mar 6, 2013 at 10:45 AM, Andrius Aučinas
>> > email to mutation-summary-d...@googlegroups.com.
>> > To post to this group, send email to
>> > mutation-sum...@googlegroups.com.
>> > Visit this group at
>> > http://groups.google.com/group/mutation-summary-discuss?hl=en.
>> > For more options, visit https://groups.google.com/groups/opt_out.
>> >
>> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "mutation-summary-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mutation-summary-d...@googlegroups.com.

Andrius Aucinas

unread,
Mar 6, 2013, 6:43:07 PM3/6/13
to mutation-sum...@googlegroups.com
That would be great. If you could make the option changeable would be even better. For example, in a similar way that disconnect() and reconnect() works. So, onlyTakeSummaries() would switch it to the mode you've just described and e.g. pushSummaries() would switch it to the way it works at the moment. To resolve any inconsistencies, takeSummaries() could be used the way it works now.


Thanks a lot!

Andrius
> > > > email to mutation-summary-d...@googlegroups.com (mailto:mutation-summary-d...@googlegroups.com).
> > > > To post to this group, send email to
> > > > mutation-sum...@googlegroups.com (http://googlegroups.com).
> > > > Visit this group at
> > > > http://groups.google.com/group/mutation-summary-discuss?hl=en.
> > > > For more options, visit https://groups.google.com/groups/opt_out.
> > >
> >
> >
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "mutation-summary-discuss" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to mutation-summary-d...@googlegroups.com (mailto:mutation-summary-d...@googlegroups.com).
> > To post to this group, send email to
> > mutation-sum...@googlegroups.com (mailto:mutation-sum...@googlegroups.com).
> > Visit this group at
> > http://groups.google.com/group/mutation-summary-discuss?hl=en.
> > For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "mutation-summary-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to mutation-summary-d...@googlegroups.com (mailto:mutation-summary-d...@googlegroups.com).
> To post to this group, send email to mutation-sum...@googlegroups.com (mailto:mutation-sum...@googlegroups.com).

Rafael Weinstein

unread,
Mar 6, 2013, 8:20:47 PM3/6/13
to mutation-sum...@googlegroups.com
Seems reasonable. Thanks.

Filed a feature request here.

https://code.google.com/p/mutation-summary/issues/detail?id=19&thanks=19&ts=1362619179

It may be a week or two before I have time to get to this. If you feel
ambitious enough to implement it, including a test, patches are
welcome. =-)
> To unsubscribe from this group and stop receiving emails from it, send an email to mutation-summary-d...@googlegroups.com.
> To post to this group, send email to mutation-sum...@googlegroups.com.

eriter

unread,
Jul 1, 2013, 1:03:49 PM7/1/13
to mutation-sum...@googlegroups.com
What's the status of this feature? I would also find this extremely useful.

I made an attempt to implement this, at least the most basic functionality which I'm looking for. It seems to work for my use case (tracking the total change between two points in time), but I don't know enough of the code base to see if I've horribly broken something.
>> > > > To post to this group, send email to
>> > > > mutation-sum...@googlegroups.com (http://googlegroups.com).
>> > > > Visit this group at
>> > > > http://groups.google.com/group/mutation-summary-discuss?hl=en.
>> > > > For more options, visit https://groups.google.com/groups/opt_out.
>> > >
>> >
>> >
>> >
>> > --
>> > You received this message because you are subscribed to the Google Groups
>> > "mutation-summary-discuss" group.
>> > To unsubscribe from this group and stop receiving emails from it, send an
>> > To post to this group, send email to
>> > Visit this group at
>> > http://groups.google.com/group/mutation-summary-discuss?hl=en.
>> > For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups "mutation-summary-discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to mutation-summary-discuss+unsub...@googlegroups.com (mailto:mutation-summary-discuss+unsubscribe@googlegroups.com).
>> To post to this group, send email to mutation-sum...@googlegroups.com (mailto:mutation-summary-dis...@googlegroups.com).
>> Visit this group at http://groups.google.com/group/mutation-summary-discuss?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "mutation-summary-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to mutation-summary-discuss+unsub...@googlegroups.com.
suspend_delivery.patch
Reply all
Reply to author
Forward
0 new messages