Dart/WebStorm “Cancel instances of dart.async.StreamSubscription”
I am using WenStorm 2018.2.5 (registered), with the Dart plugin.
While editing a simple code, the editor shows me a message:
Cancel instances of dart.async.StreamSubscription

I don't understand what this message means. I don't see what's wrong with the code. And, if I run the code inspection, the result is : "No suspicious code found".
Any idea ?
Note :
const int eventsCount = 5;
const int waitBetweenTwoEvents = 1;
typedef Streamer = Stream<int> Function();
...
Streamer streamCreator = () async* {
for(int i=0; i<eventsCount; i++) {
yield i;
sleep(Duration(seconds: waitBetweenTwoEvents));
}
};
dart webstorm
add a comment |
I am using WenStorm 2018.2.5 (registered), with the Dart plugin.
While editing a simple code, the editor shows me a message:
Cancel instances of dart.async.StreamSubscription

I don't understand what this message means. I don't see what's wrong with the code. And, if I run the code inspection, the result is : "No suspicious code found".
Any idea ?
Note :
const int eventsCount = 5;
const int waitBetweenTwoEvents = 1;
typedef Streamer = Stream<int> Function();
...
Streamer streamCreator = () async* {
for(int i=0; i<eventsCount; i++) {
yield i;
sleep(Duration(seconds: waitBetweenTwoEvents));
}
};
dart webstorm
add a comment |
I am using WenStorm 2018.2.5 (registered), with the Dart plugin.
While editing a simple code, the editor shows me a message:
Cancel instances of dart.async.StreamSubscription

I don't understand what this message means. I don't see what's wrong with the code. And, if I run the code inspection, the result is : "No suspicious code found".
Any idea ?
Note :
const int eventsCount = 5;
const int waitBetweenTwoEvents = 1;
typedef Streamer = Stream<int> Function();
...
Streamer streamCreator = () async* {
for(int i=0; i<eventsCount; i++) {
yield i;
sleep(Duration(seconds: waitBetweenTwoEvents));
}
};
dart webstorm
I am using WenStorm 2018.2.5 (registered), with the Dart plugin.
While editing a simple code, the editor shows me a message:
Cancel instances of dart.async.StreamSubscription

I don't understand what this message means. I don't see what's wrong with the code. And, if I run the code inspection, the result is : "No suspicious code found".
Any idea ?
Note :
const int eventsCount = 5;
const int waitBetweenTwoEvents = 1;
typedef Streamer = Stream<int> Function();
...
Streamer streamCreator = () async* {
for(int i=0; i<eventsCount; i++) {
yield i;
sleep(Duration(seconds: waitBetweenTwoEvents));
}
};
dart webstorm
dart webstorm
edited Nov 12 '18 at 15:52
Günter Zöchbauer
317k66940884
317k66940884
asked Nov 12 '18 at 15:40
Denis BeuriveDenis Beurive
94
94
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
This is shown when you have the linter rule enabled in analysis_options.yaml
linter:
rules:
- cancel_subscriptions
Either
- add
subscription.cancel()somewhere in that class. - remove the linter rule
- add a comment
// ignore: cancel_subscriptionsthe line before or at the end of the line that shows the warning - add a comment
// ignore_for_file: cancel_subscriptionssomewhere in the file
Thank you very much. I am not sure but I think that a stream subscription should be cancelled in order to allow the interpreter to make some clean up : "The stream may need to shut down the source of events and clean up after the subscription is canceled. Returns a future that is completed once the stream has finished its cleanup".
– Denis Beurive
Nov 12 '18 at 16:48
That's why the linter rule exists, but the linter rule doesn't understand your program. For example you might pass a reference to your subscription somewhere else to be cancelled there and the linter rule would not be able to follow that logic. You also might want to consume all events until the stream itself closes and don't intend to unsubscribe.
– Günter Zöchbauer
Nov 12 '18 at 16:51
add a comment |
As others have pointed out, you have a lint that requires you to cancel subscriptions.
In this case, I would just not create a subscription at all. Stream subscriptions are great when you want to control the stream by pausing or cancelling it early, or handling errors.
Here you just want to do something for each data event. That's what the Stream.forEach method does. It even returns a future that is completed when the stream is done or has errored, so you don't need to do subscription.asFuture.
Yes, I agree. However, I am learning Dart and I try many things in order to test my comprehension. This code is just an experiment.
– Denis Beurive
Nov 13 '18 at 14:34
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53265478%2fdart-webstorm-cancel-instances-of-dart-async-streamsubscription%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
This is shown when you have the linter rule enabled in analysis_options.yaml
linter:
rules:
- cancel_subscriptions
Either
- add
subscription.cancel()somewhere in that class. - remove the linter rule
- add a comment
// ignore: cancel_subscriptionsthe line before or at the end of the line that shows the warning - add a comment
// ignore_for_file: cancel_subscriptionssomewhere in the file
Thank you very much. I am not sure but I think that a stream subscription should be cancelled in order to allow the interpreter to make some clean up : "The stream may need to shut down the source of events and clean up after the subscription is canceled. Returns a future that is completed once the stream has finished its cleanup".
– Denis Beurive
Nov 12 '18 at 16:48
That's why the linter rule exists, but the linter rule doesn't understand your program. For example you might pass a reference to your subscription somewhere else to be cancelled there and the linter rule would not be able to follow that logic. You also might want to consume all events until the stream itself closes and don't intend to unsubscribe.
– Günter Zöchbauer
Nov 12 '18 at 16:51
add a comment |
This is shown when you have the linter rule enabled in analysis_options.yaml
linter:
rules:
- cancel_subscriptions
Either
- add
subscription.cancel()somewhere in that class. - remove the linter rule
- add a comment
// ignore: cancel_subscriptionsthe line before or at the end of the line that shows the warning - add a comment
// ignore_for_file: cancel_subscriptionssomewhere in the file
Thank you very much. I am not sure but I think that a stream subscription should be cancelled in order to allow the interpreter to make some clean up : "The stream may need to shut down the source of events and clean up after the subscription is canceled. Returns a future that is completed once the stream has finished its cleanup".
– Denis Beurive
Nov 12 '18 at 16:48
That's why the linter rule exists, but the linter rule doesn't understand your program. For example you might pass a reference to your subscription somewhere else to be cancelled there and the linter rule would not be able to follow that logic. You also might want to consume all events until the stream itself closes and don't intend to unsubscribe.
– Günter Zöchbauer
Nov 12 '18 at 16:51
add a comment |
This is shown when you have the linter rule enabled in analysis_options.yaml
linter:
rules:
- cancel_subscriptions
Either
- add
subscription.cancel()somewhere in that class. - remove the linter rule
- add a comment
// ignore: cancel_subscriptionsthe line before or at the end of the line that shows the warning - add a comment
// ignore_for_file: cancel_subscriptionssomewhere in the file
This is shown when you have the linter rule enabled in analysis_options.yaml
linter:
rules:
- cancel_subscriptions
Either
- add
subscription.cancel()somewhere in that class. - remove the linter rule
- add a comment
// ignore: cancel_subscriptionsthe line before or at the end of the line that shows the warning - add a comment
// ignore_for_file: cancel_subscriptionssomewhere in the file
answered Nov 12 '18 at 15:49
Günter ZöchbauerGünter Zöchbauer
317k66940884
317k66940884
Thank you very much. I am not sure but I think that a stream subscription should be cancelled in order to allow the interpreter to make some clean up : "The stream may need to shut down the source of events and clean up after the subscription is canceled. Returns a future that is completed once the stream has finished its cleanup".
– Denis Beurive
Nov 12 '18 at 16:48
That's why the linter rule exists, but the linter rule doesn't understand your program. For example you might pass a reference to your subscription somewhere else to be cancelled there and the linter rule would not be able to follow that logic. You also might want to consume all events until the stream itself closes and don't intend to unsubscribe.
– Günter Zöchbauer
Nov 12 '18 at 16:51
add a comment |
Thank you very much. I am not sure but I think that a stream subscription should be cancelled in order to allow the interpreter to make some clean up : "The stream may need to shut down the source of events and clean up after the subscription is canceled. Returns a future that is completed once the stream has finished its cleanup".
– Denis Beurive
Nov 12 '18 at 16:48
That's why the linter rule exists, but the linter rule doesn't understand your program. For example you might pass a reference to your subscription somewhere else to be cancelled there and the linter rule would not be able to follow that logic. You also might want to consume all events until the stream itself closes and don't intend to unsubscribe.
– Günter Zöchbauer
Nov 12 '18 at 16:51
Thank you very much. I am not sure but I think that a stream subscription should be cancelled in order to allow the interpreter to make some clean up : "The stream may need to shut down the source of events and clean up after the subscription is canceled. Returns a future that is completed once the stream has finished its cleanup".
– Denis Beurive
Nov 12 '18 at 16:48
Thank you very much. I am not sure but I think that a stream subscription should be cancelled in order to allow the interpreter to make some clean up : "The stream may need to shut down the source of events and clean up after the subscription is canceled. Returns a future that is completed once the stream has finished its cleanup".
– Denis Beurive
Nov 12 '18 at 16:48
That's why the linter rule exists, but the linter rule doesn't understand your program. For example you might pass a reference to your subscription somewhere else to be cancelled there and the linter rule would not be able to follow that logic. You also might want to consume all events until the stream itself closes and don't intend to unsubscribe.
– Günter Zöchbauer
Nov 12 '18 at 16:51
That's why the linter rule exists, but the linter rule doesn't understand your program. For example you might pass a reference to your subscription somewhere else to be cancelled there and the linter rule would not be able to follow that logic. You also might want to consume all events until the stream itself closes and don't intend to unsubscribe.
– Günter Zöchbauer
Nov 12 '18 at 16:51
add a comment |
As others have pointed out, you have a lint that requires you to cancel subscriptions.
In this case, I would just not create a subscription at all. Stream subscriptions are great when you want to control the stream by pausing or cancelling it early, or handling errors.
Here you just want to do something for each data event. That's what the Stream.forEach method does. It even returns a future that is completed when the stream is done or has errored, so you don't need to do subscription.asFuture.
Yes, I agree. However, I am learning Dart and I try many things in order to test my comprehension. This code is just an experiment.
– Denis Beurive
Nov 13 '18 at 14:34
add a comment |
As others have pointed out, you have a lint that requires you to cancel subscriptions.
In this case, I would just not create a subscription at all. Stream subscriptions are great when you want to control the stream by pausing or cancelling it early, or handling errors.
Here you just want to do something for each data event. That's what the Stream.forEach method does. It even returns a future that is completed when the stream is done or has errored, so you don't need to do subscription.asFuture.
Yes, I agree. However, I am learning Dart and I try many things in order to test my comprehension. This code is just an experiment.
– Denis Beurive
Nov 13 '18 at 14:34
add a comment |
As others have pointed out, you have a lint that requires you to cancel subscriptions.
In this case, I would just not create a subscription at all. Stream subscriptions are great when you want to control the stream by pausing or cancelling it early, or handling errors.
Here you just want to do something for each data event. That's what the Stream.forEach method does. It even returns a future that is completed when the stream is done or has errored, so you don't need to do subscription.asFuture.
As others have pointed out, you have a lint that requires you to cancel subscriptions.
In this case, I would just not create a subscription at all. Stream subscriptions are great when you want to control the stream by pausing or cancelling it early, or handling errors.
Here you just want to do something for each data event. That's what the Stream.forEach method does. It even returns a future that is completed when the stream is done or has errored, so you don't need to do subscription.asFuture.
edited Nov 13 '18 at 12:40
answered Nov 13 '18 at 7:31
lrnlrn
9,8941319
9,8941319
Yes, I agree. However, I am learning Dart and I try many things in order to test my comprehension. This code is just an experiment.
– Denis Beurive
Nov 13 '18 at 14:34
add a comment |
Yes, I agree. However, I am learning Dart and I try many things in order to test my comprehension. This code is just an experiment.
– Denis Beurive
Nov 13 '18 at 14:34
Yes, I agree. However, I am learning Dart and I try many things in order to test my comprehension. This code is just an experiment.
– Denis Beurive
Nov 13 '18 at 14:34
Yes, I agree. However, I am learning Dart and I try many things in order to test my comprehension. This code is just an experiment.
– Denis Beurive
Nov 13 '18 at 14:34
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53265478%2fdart-webstorm-cancel-instances-of-dart-async-streamsubscription%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown