4 ms·
There's usually no render function to call in these types of frameworks as far as I understand (my experience being a little Svelte). I imagine in your scenari
by have_faith 6y ago
There's usually no render function to call in these types of frameworks as far as I understand (my experience being a little Svelte).
I imagine in your scenario the psuedo code to achieve what you want would be written.
list2 = bubble_sort(list1)
removeItem = () => delete list2[random index]
...
<for each list2 render div>
The compiler will see a change to the list2 variable anywhere that removeItem is called and annotate the code to make the appropriate changes to the dom in the function call and the bubble_sort line will never be re-run unless it was explicitly added to the removeItem function.
- ryansolid 6y agoCorrect. The idea is that the derived state only updates when the underlying state updates. And the mapping to the DOM is just derived from that derived state. So list updates.. triggers bubble sort, triggers DOM reconciliation. The difference with Svelte is it sees it and the compiler writes the reactive code in the background. In Solid you just write the reactive code yourself.. ie.. `setState` etc. But it more or less works similarly. It's like Svelte without abstracting the update mechanism. Which makes it a little more to get into at first but very similar to a library like React. The difference from React is that Solid knows exactly what you are updating so it doesn't bother with the other stuff.
- amelius 6y agoNote that the item is deleted from list1. The framework should (I suppose) track that list2 depends on list1 through bubble_sort(). Are the dependencies implicit? Or should they be declared explicitly?
- ryansolid 6y agoGenerally implicitly either through proxy or get method read. Solid provides an explicit API as well.