Skip to content

Commit

Permalink
add state to didUpdate, fix viewUpdated
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseditson committed Jun 17, 2024
1 parent 948bcfa commit 1605eb4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/upd8.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const visibleViews = new Set();
export type Config<State, Event> = {
setHidden?: (el: HTMLElement, hidden: boolean) => void;
viewUpdated?: (screen: Upd8View<State, Event>) => void;
didUpdate?: () => void;
didUpdate?: (state: State) => void;
};

export type ImperativeUpd8Fn<State, Event> = (
Expand Down Expand Up @@ -40,7 +40,7 @@ export const cre8 = <State, Event>(
throw new Error("upd8 may only be initialized once.");
}
for (const ViewK of allViews) {
const view = new ViewK(state, config.didUpdate);
const view = new ViewK(state, config.viewUpdated);
if (views.has(view.id)) {
throw new Error(`View ${view.id} already exists.`);
}
Expand All @@ -64,7 +64,7 @@ export const cre8 = <State, Event>(
visibleViews.delete(view.id);
}
}
config.didUpdate();
config.didUpdate(state);
};
setTimeout(() => upd8(state), 0);
return upd8;
Expand Down

0 comments on commit 1605eb4

Please sign in to comment.