rocicorp / rails

Replicache on Rails
Other
34 stars 3 forks source link

zql [3/n] - allow statements to be cleaned up / destroyed #31

Closed tantaman closed 8 months ago

tantaman commented 8 months ago

Adds an explicit destroy method to Statement.

Destroy starts at the leaves and walk up the graph, destroying readers/writers & operators as they are encountered.

If a writer is encountered with multiple readers only the currently destroyed reader is removed and the walk stops. This would be the case if the graph was forked --

const pipeline1 = source.map();
const pipeline2 = pipeline1.filter();
const pipeline3 = pipeline1.filter();

//      s
//      |
//     p1
//   /    \
// p2      p3

Destroying p2 does not destroy p1. Destroying p3 sometime later would destroy p1.

tantaman commented 8 months ago

converting to draft -- have a slightly different idea.