Using streams with recursive and/or deeply nested schemas

Yes, that true, and I make use of that. However, and this is at the heart of the problem, that applies to assigns and not to streams because assigns stay in memory so there is the previous value to compare a new one to. With streams the server does not keep the previous value around so cannot diff and the client has the dynamix parts derived from the record in the DOM but not the whole original record. That’s what’s been cathing folks out when trying to use streams. It’s not as big an issue for linear data like a list of records (though some would say it is) but when it comes to serving big recursive data to large numbers of clients, the option of keeping a potentially explosive amount of data in session memory for detecting changes becomes too expensive to contemplate in a production setting, and that’s where the approach I’m developing come in handy.

I make full use of LVs ability to diff assigns but the idea is to not put the actual record data in assigns. Only structure data goes into the assigns, and only after being restricted at the database level to represent one exacting rectangular slice of the data. You may have a different opinion but from where I’m approaching this that is small, contained and controllable enough to keep in memory so LV can do its thing. Which “data” records are to be sent from the server to the client then becomes a matter of calculating the difference (in set terms) between the MapSet of keys for which there is HTML on the client already and the MapSet of keys the client should be showing after the update and sending the HTML generated for those through using the streams update mechanism. Any record from the MapSet that should be on the serve that we know from the business logic or PubSub subscription has changed since it was last sent through, is also added to the stream and thus updated on the client screen.

I don’t know if this is making sense to you (yet). I fell a bit behind over the weekend with the planned publish of the code I have, but I should have it on the repository soon. That will give us something more concrete to discuss and therefor hopefully somewhat easier. Right now you’re having to guess at what I’m actually referring to so it probably sounds like a load of waffle.

1 Like