1
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MVVM+ReduxでWPFアプリをC#+F#で作成

Posted at

動機

  • Reduxというものを知り、WPFアプリ作成に使えるかどうか試したい
  • C#とF#を両方使ってみたい

環境、使用したライブラリ・フレームワークなど

参考にしたのは、こちらのストップウォッチアプリです。

ソース

感想

  • StateをF#のレコードにしたおかげで、前のStateから次のStateを作る部分がすっきり書けた。C#では、こうは簡単にはできない。
Reducers.fs
static member private TimerReducer(previousState : ApplicationState, action : TimerAction) : ApplicationState = 
        { previousState with NowSpan = action.Now - previousState.StartTime
                             Now = action.Now }
  • MVVMではMの部分をどうするか迷うのだが、Reducer、Store、State等に分けることで、役割がはっきりした。VMは、Dispatchと監視・反映を行う。
1
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?