Does mkProgram provide more functionality than mkSimple?

I am trying to understand the difference between mkSimple and mkProgram in Fable-Elmish or Elmish.WPF, which I actually use. (Can someone possibly create a tag for elmish.wpf, please?)

I found Elmish.WPF incredibly effective, I use it in production, but I'm at a stage where I still learn a lot every day. This particular question is taking up too much of my research time, so I would appreciate help.

Comments in the source are as follows.

mkSimple: Simple program that produces only new state with 'init' and 'update'.

mk program: Typical program, new commands are produced by 'init' and 'update' along with the new state.

So what are these commands for? I looked at the examples in several places, but they do not really matter if I can do the same with mkSimple as with mkProgram, and this is what I need to know.

Does mkProgram provide some functions that mkSimple does not do, or can everything be executed no matter what I use? Is mkSimple just for a simple demo use, and should I use mkProgram for real world applications that are growing? If you can do everything with both, then why the difference?

+4
source share
1 answer

mkSimplevalid for educational purposes only. This helps facilitate new users within the framework without introducing ideas Cmd.

If you look at the source mkSimple , you will see that everything that it does hides the idea Cmd(by using Cmd.none) and calls mkProgram:

/// Simple program that produces only new state with `init` and `update`.
let mkSimple 
    (init : 'arg -> 'model) 
    (update : 'msg -> 'model -> 'model)
    (view : 'model -> Dispatch<'msg> -> 'view) =
    { init = init >> fun state -> state,Cmd.none
      update = fun msg -> update msg >> fun state -> state,Cmd.none
      view = view
      setState = fun model -> view model >> ignore
      subscribe = fun _ -> Cmd.none
      onError = onError }

Elm Architecture, beginnerProgram.

, mkProgram. , mkSimple.

+5

Source: https://habr.com/ru/post/1684114/


All Articles