fix(task): remove cancel method from Task trait(#884)#899
Merged
Conversation
jstarry
approved these changes
Jan 26, 2020
Member
jstarry
left a comment
There was a problem hiding this comment.
just a few nits, the expect messages aren't accurate anymore. Otherwise this looks good, thanks!
| let handle = self | ||
| .0 | ||
| .take() | ||
| .expect("tried to cancel request fetching twice"); |
Member
There was a problem hiding this comment.
nit: this is no longer accurate, unwrap should be fine because this is impossible now
| fn drop(&mut self) { | ||
| if self.is_active() { | ||
| self.cancel(); | ||
| let handle = self.0.take().expect("tried to cancel interval twice"); |
Member
There was a problem hiding this comment.
nit: same here, unwrap should be fine
096192e to
26491d4
Compare
Contributor
Author
|
@jstarry changed. |
jstarry
reviewed
Jan 27, 2020
| } | ||
| WsAction::Disconnect => { | ||
| self.ws.take().unwrap().cancel(); | ||
| drop(self.ws.take().unwrap()); |
Member
There was a problem hiding this comment.
Drop will be called once the task goes out of scope so self.ws.take() should be enough
| @@ -77,7 +77,7 @@ impl Component for Model { | |||
| } | |||
| Msg::Cancel => { | |||
| if let Some(mut task) = self.job.take() { | |||
In order to avoid misuse It was decided to remove `cancel` from `Task` trait and delegate such logic to `Drop`.
Contributor
Author
|
@jstarry changed. Thanks for the review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #884.
In order to avoid misuse It was decided to remove
cancelfromTasktraitand delegate such logic to
Drop.