SolidJSS
SolidJSโ€ข4y agoโ€ข
8 replies
sebb8200

how to use from or reconcile with an external producer

I try to use an external store (https://github.com/nerdslabs/storex) with solid.

To try it out I copied the https://www.solidjs.com/tutorial/stores_createstore?solved example and replaced addTodo() with a commit to the external store.

The store seems to produce data just fine. This is the console output from the subscribe callback below (After I created the first todo from the frontend).
[
    {
        "completed": false,
        "id": "72b6f1d6-7748-11ed-a08c-e86a64e00a8b",
        "text": "aaa"
    }
]

This is how I update the solid store using reconcile.
const [todos, setTodos] = createStore([]);

store.subscribe((update) => {
  console.log("update", update);
  if (update) setTodos(reconcile(update, { key: "id" }));
});


This first todo is rendered correctly. But when I add another todo, the first is rendered again.

I attached a screenshot from the inspector where you can see, that the console.log("Creating... outputs aaa twice but the update in the subscribe callback has the right data.

When using from I have the same problem.

Any pointers are greatly appreciated. I'd love to use solid and Elixir to replace a mad Angular App with Python backend.

Thank you!
image.png
image.png
Was this page helpful?