diff --git a/README.md b/README.md
index 5b4e985..6c97a09 100644
--- a/README.md
+++ b/README.md
@@ -139,8 +139,8 @@ export const Todos = component("Todos", (props, { signal, wire, store }) => {
{
- return - {item.task}
;
+ renderItem={(cursor) => {
+ return - {cursor().task}
;
}}
>
@@ -241,8 +241,8 @@ export const Prosemirror = component("Prosemirror", (props, { onUnmount }) => {
```tsx
{
- return {wire(item.task)};
+ renderItem={(cursor) => {
+ return {wire(cursor().task)};
}}
>
```
diff --git a/package.json b/package.json
index 1043f66..676b925 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "alfama",
- "version": "1.2.8",
+ "version": "1.3.0",
"author": "Abhishiv Saxena",
"license": "MIT",
"description": "Fine-grained reactive library with no compiler, no magic, and no virtual DOM",
diff --git a/src/core/state/storeAPI.ts b/src/core/state/storeAPI.ts
index 6f95851..93ef9e8 100644
--- a/src/core/state/storeAPI.ts
+++ b/src/core/state/storeAPI.ts
@@ -48,9 +48,10 @@ export const reify = (cursor: T): T => {
export const produce = (
cursor: T,
- setter: (obj: T) => void
+ setter: (obj: T) => void,
+ fv?: any
): void => {
- const v = reify(cursor);
+ const v = fv ? fv : reify(cursor);
setter(v);
};
diff --git a/src/stdlib/Each/index.tsx b/src/stdlib/Each/index.tsx
index 03736fe..26850e6 100644
--- a/src/stdlib/Each/index.tsx
+++ b/src/stdlib/Each/index.tsx
@@ -60,6 +60,10 @@ export const Each: (
if (!isArray) throw new Error(" needs array");
const getItemCursor = (item: ExtractElement) => {
+ const listValue: typeof listCursor = getValueUsingPath(
+ store.value as any,
+ listCursorPath
+ ) as typeof listCursor;
const index = listValue.indexOf(item);
if (index > -1) {
return props.cursor[index];
@@ -73,12 +77,11 @@ export const Each: (
//console.log("Each list change", change, listCursorPath, path);
const pStep = parentStep.children[0];
const previousChildren = [...(pStep.children || [])];
+ // list reset
if (listCursorPath.join() === path.join() && !data) {
previousChildren.forEach((node) => {
removeNode(renderContext, node);
});
- //console.log("should reset list");
-
const startIndex = 0;
(value as typeof props.cursor).forEach((item, index) => {
const previousChildren = [...(pStep.children || [])];