Closed amiakotin closed 7 years ago
Merging #22 into master will not change coverage. The diff coverage is
n/a
.
@@ Coverage Diff @@
## master #22 +/- ##
========================================
Coverage 92.3% 92.3%
Complexity 199 199
========================================
Files 25 25
Lines 754 754
Branches 89 89
========================================
Hits 696 696
Misses 42 42
Partials 16 16
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 56ed0ad...076dbbb. Read the comment docs.
Hi @amiakotin,
Thanks for your effort for this contribution.
But this interface was intentionally left as Observable<Object>
to be consistent with Store
and Dispatcher
dispatch(Object action)
.
That was done in Store
to be able to pass arbitrary objects to be handled by Middlewares.
The same applies for epics: epic can return the stream of "actions" which can be processed by a Middleware.
You can return Observable
@Yarikx thanks for explanation. The reason I thought a change was needed was because I was struggling with chaining .observeOn(AndroidSchedulers.mainThread()
to the observable that Epic.run
returned. This wasn't compiling:
Epic<AppState> epic = (actions, store) -> actions
.filter(Epics.ofType(NotesActions.ADD_ASYNC))
.delay(1, TimeUnit.SECONDS)
.map(action -> Action.create(NotesActions.ADD_ACTION, action.values))
.observeOn(AndroidSchedulers.mainThread());
However, using an intermediate var helped:
Epic<AppState> epic = (actions, store) -> {
Observable<Object> obs = actions
.filter(Epics.ofType(NotesActions.ADD_ASYNC))
.delay(1, TimeUnit.SECONDS)
.map(action -> Action.create(NotesActions.ADD_ACTION, action.values));
return obs.observeOn(AndroidSchedulers.mainThread());
};
I'm closing since no changes are needed.
This change makes the interface consistent with the intent of accepting a stream of Actions and returning another stream of Actions. The type of
Observable<Object>
was preventing me from performing other operations on the returned observable, such as.subscribeOn(Schedulers.io)
and.observeOn(AndroidSchedulers.mainThread()
.