DNS: more consistent and realistic handling of DNS events #1661
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes inspired by a comment by @stephanethomas.
Previously, we optimistically deleted the DNS record. Now, we wait for the response from the API. Same for adding DNS records.
The
DNS_*_COMPLETED
events are now only fired when there's no error, making reducer implementation more straightforward.I did not add the
DNS_DELETE
andDNS_ADD
events, since they are not needed right now and might suggest that something is happening (or should be) when they are fired. If someone will need them (for example, when implementing optimistic versions of those actions), it's trivial to add them.While getting rid of the
onComplete
callback and keeping everything pure was tempting (as discussed with Stephane), looking at the fluxing (ha-ha, get it?) approach to Redux usage right now in Calypso, I decided it's beyond my abilities at the moment. But I'll keep a close eye on the developments in this area and when I'll educate myself and have some spare cycles I'll get back to this :)cc: