How can I specify type annotations in Dart with `combineReducers`?
The correct type I needed to use was:
final Function profileReducer = combineReducers<Profile>(<Profile Function(Profile, dynamic)>[ TypedReducer<Profile, FetchProfileResultAction>(_setProfile),]);
But to make that more usable, I created a type:
import 'package:utgard/store/models/profile.dart';typedef ProfileReducers = Profile Function(Profile, dynamic);
Then I can use in my reducers, like so:
final Function profileReducer = combineReducers<Profile>(<ProfileReducers>[ TypedReducer<Profile, FetchProfileResultAction>(_setProfile),]);
Dart doesn't support union type so typing actions properly won't be possible.. A "less realistic type" will be required
You can do the following:
final profileReducer = combineReducers<Profile>(<TypedReducer<Profile, Action>>[ TypedReducer<Profile, UpdateProfileBalanceAction>(_updateProfileBalance), TypedReducer<Profile, FetchProfileResultAction>(_setProfile),]);