hyperknot
Explore posts from serversHow to modify array partially?
I see, it supports infinite variety of arguments. It was just a particular case of my store, that the normal case was ('key', value) and the more advanced case was 3 params, but now I understand it could have been 3+ params as well.
33 replies
How to modify array partially?
I don't follow that. I wanted to write 3 scenarios, where
- everything is updated, that was my scenario as of yesterday
- reconcile runs the diffing algorithm with deep comparison, possibly nothing is updated
- the third one is similar to your
[...prevState, newItem]
example, resulting in a partial update for For
.
Or at least I tried to write these33 replies
How to modify array partially?
Not exactly. I know that signals are tracked through proxies, and I guess each item of an array proxy has it's own identity.
I guess <For> uses these identities of the array proxy to check if a child-component needs an update or not.
33 replies
How to modify array partially?
These are not LLM tokens, but tokens from my markdown parser, so for example a full code block is a single token. I think there won't be too many of them in a single message of a normal chat conversation.
I've looked into the keyed version, but I cannot generate real keys, only derived ones. For example I could make {type: 't', content: 'c'} into an ID: "t_c". But this will result in duplicates for example simple tokens like
<hr/>
will be repeated.
So in conclusion, reading the code, I believe the non-keyed version will be perfect for my use case.
What's left to understand is the connection between <For> and the reconcile/applyState.33 replies
How to modify array partially?
I'm also reading the source code. What's interesting is that in my use case (streaming text, only the last section changes) it seems to work perfectly without supplying an id.
And afaik the deep comparison happens because of the recursive nature of applyState
33 replies
How to modify array partially?
I'm really happy with reconcile, basically it contains the same prefix matching algorithm which I was about to implement. It's super nice.
One thing which isn't clear is it can take a key param. Is that totally optional? If my array consists of objects, does it do deep comparison if a key is not supplied?
33 replies
How to modify array partially?
Is it possible that it's as simple as using reconcile? Does it do all the magical deduplication?
But how does it work? I mean how can reconcile compare two arrays if the only parameter it has is a single array?
33 replies