Skip to content

Commit

Permalink
Merge pull request #24 from ar90n/feature/update-only-if-state-change…
Browse files Browse the repository at this point in the history
…-occurs

perf: Update only if state change occurs
  • Loading branch information
ar90n authored May 31, 2022
2 parents 980af46 + f023ec2 commit 585fb37
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions alfort/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,11 @@ def render() -> None:
def dispatch(msg: M) -> None:
nonlocal state
nonlocal root
(state, effects) = self._update(msg, state)
# TODO: should check state has been changed
self._subscriber.update(state, dispatch)
self._enqueue(render)
old_state = state
(state, effects) = self._update(msg, old_state)
if state != old_state:
self._subscriber.update(state, dispatch)
self._enqueue(render)
self._run_effects(dispatch, effects)

self._subscriber.update(state, dispatch)
Expand Down

0 comments on commit 585fb37

Please sign in to comment.