Skip to content

Commit

Permalink
Merge pull request #1043 from fabulous-dev/sync-view-fn-ui-thread
Browse files Browse the repository at this point in the history
Ensure view function is only called on UI thread
  • Loading branch information
TimLariviere committed Jun 1, 2023
2 parents 149c06e + 272a80c commit b3c9894
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

_No unreleased changes_
### Changed
- `view` function now runs only on the UI thread by @TimLariviere (https://github.com/fabulous-dev/Fabulous/pull/1043)

## [2.3.1] - 2023-05-22

Expand Down
14 changes: 7 additions & 7 deletions src/Fabulous/Runners.fs
Original file line number Diff line number Diff line change
Expand Up @@ -206,16 +206,16 @@ module ViewAdapters =
member _.OnStateChanged(args) =
try
if args.Key = stateKey then
let state = unbox args.NewState
syncAction(fun () ->
try
let state = unbox args.NewState

let prevWidget = _widget
let currentWidget = (view state).Compile()
_widget <- currentWidget
let prevWidget = _widget
let currentWidget = (view state).Compile()
_widget <- currentWidget

let node = getViewNode _root
let node = getViewNode _root

syncAction(fun () ->
try
Reconciler.update canReuseView (ValueSome prevWidget) currentWidget node
with ex ->
if not(exceptionHandler ex) then
Expand Down

0 comments on commit b3c9894

Please sign in to comment.