0.6.0-preview6 #254
JordanMarr
announced in
Announcements
Replies: 1 comment 1 reply
-
Why the keys of subscription functions are wrapped in list? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This pre-release version includes:
useElmish
hookUpgraded to Elmish v4 (Breaking)
1) Breaking Changes to UI Thread Sync
Program.withSyncDispatch
has been removed in Elmish v4 because the platform specificProgram.runWith___
functions should instead be provided by the library authors.Additional info
the purpose of the "sync dispatch" is to ensure that UI changes coming from non-UI threads can be properly synchronized via the underlying platform specific dispatcher to avoid race conditions.
Previously, FuncUI automatically configured this within the
Program.withHost
function, on behalf of the user, to guard against race conditions that could occur if they calleddispatch
from anasync
handler.Avalonia.FuncUI upgrade path
A new
Program.runWithAvaloniaSyncDispatch
function has been added that conforms to the new expectation that this should be handled by the library. Users that are callingdispatch
from withinasync
blocks will need to know to use this instead ofProgram.run
. If they don't, the will get exceptions, which will then force them to use this new function.Unfortunately, this does mean that users will need to be responsible for using
Program.runWithAvaloniaSyncDispatch
vsProgram.run
. However, we can accomplish this via a "breaking changes update guide". Also, I think it is common for users to have some understanding of thread dispatching concerns and how to handle it properly.Old Elmish v3 Sample with async blocks
New Elmish v4 Sample with async blocks
2) Breaking Changes to Subscriptions
Cmd.ofSub
has been removedProgram.withSubscription
now takes in the state/model, and returns a list of named subscriptions.IDisposable
so they can be automatically disposedThe above changes will cause breakage in any FuncUI apps that make use of
Program.withSubscription
.Avalonia.FuncUI upgrade path
Any FuncUI app that was previously using
Program.withSubscription
will have to resolve a build error since the function inputs/outputs have changed.Old Elmish v3 Sample with Multiple Subscriptions
New Elmish v4 Sample with Multiple Subscriptions
Completely reworked useElmish hook (Breaking)
useElmish
now actually uses Elmish 4 under the hood! 🎉This means that
useElmish
can now take advantage of all the great Elmish features like subscriptions and async commands!It has two main variations of overloads:
init
,update
,initArg
and an optionalmapProgram
(for adding subsriptions or other Elmish extensions)writableModel
,update
and an optionalmapProgram
(for adding subsriptions or other Elmish extensions)Here is an example from the
ChordParserView
sample that uses subscriptions:This discussion was created from the release 0.6.0-preview6.
Beta Was this translation helpful? Give feedback.
All reactions