Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MVU like updates #11

Open
kekyo opened this issue Jun 10, 2021 · 1 comment
Open

MVU like updates #11

kekyo opened this issue Jun 10, 2021 · 1 comment

Comments

@kekyo
Copy link
Owner

kekyo commented Jun 10, 2021

First time idea, F# can declare immutable type named record. The record usage is simple and safer than standard class type.
If it uses on a ViewModel, could update any property only construction time, but will be made clean and FP like manner.
So we can write update handler only returning new instance of record like MVU.

Pseudo code fragment (can't compile):

// It's a F# record type
type SampleViewModel = {
  
  // The handler would return a value `Async<SampleViewModel>`:
  self.Clicked = CommandFactory.create (fun e:EventArgs -> async {
      return { self.a, self.b self.c+1 }
  }
}

The record type contains getter property and (hidden?) setter property, and they have propchange capability. It code surface has only getter in F# (and C#?) syntax likes purely, but generated binary will have propchange impls. Command handler will transfer each props at returned from handler function. They will call propchanged callback if value is changed.

@tatsuya-midorikawa told me it basic idea.

@tatsuya-midorikawa
Copy link

BTW, Elmish.WPF may give you some ideas on how to implement MVU👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants