-
Notifications
You must be signed in to change notification settings - Fork 87
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
[WIP] Awaitable store with async saga support #62
base: master
Are you sure you want to change the base?
Conversation
@dcolthorp It should be exception safe now. Calling I've added a ton of tests, check them out to see how it's used. Some tests might be unnecessary due to being pretty much being guaranteed by .NET, but much of it was copy-paste and I didn't stop to think too hard on whether all the tests were strictly needed. |
I've updated the initial comment with more information. @dcolthorp Regarding #47 (comment) and your mention of |
This is a work in progress. Posting here as a PR so we can discuss. Particularly interested in what @dcolthorp has to say. Regarding #47 (comment), this PR provides a way of registering sagas using an action observable AND awaiting the completion of all actions in the store. See unit tests for details.
Due to necessity I branched this off of my previous branch (PR #60), hence why the commit from that PR also shows up in this PR.
I've just lumped all code together in one file for now.
The distinct features in this PR are:
The following two delegates denoting async/blocking sagas:
void Saga(action, store)
Task AsyncSaga(action, store)
I'm considering changing this a bit so that they only accept an
action
parameter, and then have the sagas be returned from a function that accepts the store. Kind of like middleware, where the middleware has access to the store through the function that creates the middleware. Removing the store parameter would make the saga register syntax look cleaner, and also removes the store parameter from sagas that don't need it. Input welcome.Two extension methods on
IObservable<T>
for registering async and non-async sagas.ObservableActionStore
which exposes an IObservable of actions. Can be dropped in favor of a simple extension toStore
if we figure out New ActionDispatched event would duplicate StateChanged #63.AwaitableStore
which exposesDispatchAsync
and also has internally accessible member(s) for keeping track of async operations thatDispatchAsync
should await (currently this is simply a methodIDisposable AsyncOperation()
to be used inusing
statements, as seen in the extension method.)The
IObservable<T>
extension methodsRunsSaga
andRunsAsyncSaga
Things to do before this can be merged: