brianegan / dart_redux_epics

Redux.dart middleware for handling actions using Dart Streams
MIT License
141 stars 22 forks source link

Combining epics and normal middleware #12

Closed arcas0803 closed 6 years ago

arcas0803 commented 6 years ago

I get an error using both types. I don't know if is an error or maybe a don't know how to handle: In the store initialization middleware: middleware().addAll([new EpicMiddleware(allEpics)]) or middleware: middleware().addAll(new EpicMiddleware(allEpics)) or middleware: [middleware(),new EpicMiddleware(allEpics)] I don't know how to combine both.

brianegan commented 6 years ago

Hey there -- Could you please provide a bit more code? It's a bit tough to know where the type error is coming in...

What is the signature of the Middleware function? If it returns a List<Middleware<AppState>>, then you might need to provide full type info to the EpicMiddleware constructor. In addition, addAll will return a void, rather than the list. This means your first two version are returning void to the middleware property. So you probably need to use either:

..addAll + type info:

middleware: middleware()..addAll([EpicMiddleware<AppState>(allEpics)])

or using the + operator with type info:

middleware: middleware() + [EpicMiddleware<AppState>(allEpics)]

Let me know if that works!

arcas0803 commented 6 years ago

..addAll solve the problem. Thanks. Closing "issue"