Skip to content

Commit

Permalink
createState: emit event on init
Browse files Browse the repository at this point in the history
  • Loading branch information
djalmajr committed Aug 11, 2023
1 parent a8c5a72 commit fad76bc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
4 changes: 1 addition & 3 deletions examples/counter.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,4 @@ function App() {
`;
}

const update = () => render(document.body, App());
store.observe(update);
update();
store.observe(() => render(document.body, App()));
1 change: 1 addition & 0 deletions src/createState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export function createState<T extends object>(data?: T, opts?: Options): State<T
if (nextTickId) cancelAnimationFrame(nextTickId);
nextTickId = requestAnimationFrame(() => fns.forEach((fn) => fn(data)));
});
emit(`update:${uid}`);

return bind(state);
}

0 comments on commit fad76bc

Please sign in to comment.