This repository was archived by the owner on Sep 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Editor component possible race condition #5
Comments
Fair point. Will put in a fix tomorrow |
@nvartolomei what do you think about #8? |
Not sure if I like this one, page change makes all requests made through promise middleware obsolete. This is too much, imho. Let's say I have a header that stays the same on all pages, an action from header will be killed in middleware if editor is unloaded? |
You're right, hadn't quite thought of that. Have any other ideas? I'll do some research and see if I can come up with something better today. |
@nvartolomei see what you think of #9 . Slightly different approach based on explicitly cancelling all tracked promises when a route unloads. |
@vkarpov15 looks good to me. |
vkarpov15
added a commit
that referenced
this issue
Apr 27, 2016
New approach for handling race condition in #5
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I was wondering if there could be a race condition.
Suppose I try to edit an article, Editor component si being mounted and
EDITOR_PAGE_LOADED
event is dispatched.The request is sent to server, but the server didn't respond yet. (1)
Now I go back to homepage, editor component is unmounted,
EDITOR_PAGE_UNLOADED
is dispatched, the state related to editor component is cleared.Now I try to edit another article, Editor component is mounted,
EDITOR_PAGE_LOADED
is dispatched for another article.The request is sent to server, and server responds instantly. (2)
Reducer for
EDITOR_PAGE_LOADED
action triggered by second request is called. Everything cool still.Now, the first request (1) is full-filled, and reducer for
EDITOR_PAGE_LOADED
action is called, with information from first request, and in the editor I will see the contents for first article I tried to edit, instead of the second one.Hm?
The text was updated successfully, but these errors were encountered: