Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Issue 1242023007: Add setters for callbacks on StreamController. (Closed)

Created:
5 years, 5 months ago by Lasse Reichstein Nielsen
Modified:
5 years, 4 months ago
Reviewers:
nweiz, *floitsch
CC:
reviews_dartlang.org
Base URL:
https://github.com/dart-lang/sdk.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Add setters for callbacks on StreamController. This allows you to create a stream controller at one point and add or change the callbacks later. This can be useful if you want to store a stream controller in a final instance field and also want the controller to call instance methods as callbacks. R=floitsch@google.com Committed: https://github.com/dart-lang/sdk/commit/4a8a844c345f8dff736f0b31f5371fd4571e1afa

Patch Set 1 #

Total comments: 2

Patch Set 2 : Address comments. #

Total comments: 14
Unified diffs Side-by-side diffs Delta from patch set Stats (+218 lines, -51 lines) Patch
M CHANGELOG.md View 1 chunk +4 lines, -0 lines 2 comments Download
M sdk/lib/async/broadcast_stream_controller.dart View 3 chunks +16 lines, -3 lines 0 comments Download
M sdk/lib/async/stream_controller.dart View 1 4 chunks +56 lines, -48 lines 8 comments Download
M tests/lib/async/stream_controller_test.dart View 2 chunks +142 lines, -0 lines 4 comments Download

Messages

Total messages: 12 (2 generated)
Lasse Reichstein Nielsen
This prevents having a "no callback" version that is not wasting the four words when ...
5 years, 5 months ago (2015-07-17 06:33:09 UTC) #3
floitsch
I'm not a big fan of mutable classes, but I can see how this makes ...
5 years, 5 months ago (2015-07-17 09:47:53 UTC) #4
Lasse Reichstein Nielsen
Committed patchset #2 (id:20001) manually as 4a8a844c345f8dff736f0b31f5371fd4571e1afa (presubmit successful).
5 years, 5 months ago (2015-07-17 10:03:18 UTC) #5
nweiz
https://codereview.chromium.org/1242023007/diff/20001/CHANGELOG.md File CHANGELOG.md (right): https://codereview.chromium.org/1242023007/diff/20001/CHANGELOG.md#newcode6 CHANGELOG.md:6: * `StreamController` added setters for the `onListen`, `onPause`, `onResume` ...
5 years, 5 months ago (2015-07-17 20:40:16 UTC) #6
Lasse Reichstein Nielsen
https://codereview.chromium.org/1242023007/diff/20001/CHANGELOG.md File CHANGELOG.md (right): https://codereview.chromium.org/1242023007/diff/20001/CHANGELOG.md#newcode6 CHANGELOG.md:6: * `StreamController` added setters for the `onListen`, `onPause`, `onResume` ...
5 years, 4 months ago (2015-08-05 09:08:45 UTC) #7
nweiz
https://codereview.chromium.org/1242023007/diff/20001/sdk/lib/async/stream_controller.dart File sdk/lib/async/stream_controller.dart (right): https://codereview.chromium.org/1242023007/diff/20001/sdk/lib/async/stream_controller.dart#newcode141 sdk/lib/async/stream_controller.dart:141: void set onListen(void onListenHandler()); On 2015/08/05 09:08:45, Lasse Reichstein ...
5 years, 4 months ago (2015-08-06 01:02:13 UTC) #8
Lasse Reichstein Nielsen
https://codereview.chromium.org/1242023007/diff/20001/sdk/lib/async/stream_controller.dart File sdk/lib/async/stream_controller.dart (right): https://codereview.chromium.org/1242023007/diff/20001/sdk/lib/async/stream_controller.dart#newcode141 sdk/lib/async/stream_controller.dart:141: void set onListen(void onListenHandler()); Well, it's quite symmetric - ...
5 years, 4 months ago (2015-08-06 07:00:41 UTC) #9
floitsch
DBC. not adding much value, but since I already wrote it... https://codereview.chromium.org/1242023007/diff/20001/sdk/lib/async/stream_controller.dart File sdk/lib/async/stream_controller.dart (right): ...
5 years, 4 months ago (2015-08-06 09:28:12 UTC) #10
Lasse Reichstein Nielsen
https://codereview.chromium.org/1242023007/diff/20001/sdk/lib/async/stream_controller.dart File sdk/lib/async/stream_controller.dart (right): https://codereview.chromium.org/1242023007/diff/20001/sdk/lib/async/stream_controller.dart#newcode141 sdk/lib/async/stream_controller.dart:141: void set onListen(void onListenHandler()); On 2015/08/06 09:28:12, floitsch wrote: ...
5 years, 4 months ago (2015-08-06 14:09:40 UTC) #11
nweiz
5 years, 4 months ago (2015-08-06 19:56:12 UTC) #12
Message was sent while issue was closed.
https://codereview.chromium.org/1242023007/diff/20001/sdk/lib/async/stream_co...
File sdk/lib/async/stream_controller.dart (right):

https://codereview.chromium.org/1242023007/diff/20001/sdk/lib/async/stream_co...
sdk/lib/async/stream_controller.dart:141: void set onListen(void
onListenHandler());
On 2015/08/06 14:09:40, Lasse Reichstein Nielsen wrote:
> On 2015/08/06 09:28:12, floitsch wrote:
> 
> > In this case I wouldn't onListen to setOnListen. If we have a method called
> > "onListen", and a field "onListen", then we screwed up the names. In
general,
> it
> > should be possible to know if something is a method or a property from the
> name.
> 
> 
> I think we did screw up that particular type of name.
> Here I made it a setter, because it really is a property (and I wouldn't mind
> adding the getters).
> On StreamSubscription it's a method. It should probably be a property as well,
> with getters (no reason to hide the callback from the owner of the
> subscription).
> in HTML an "onClick" is a stream of events that you can listen to.
> In other cases it's a parameter name.
> 
> The thing they have in common is that they are ways of adding callbacks.
> For StreamSubscription and StreamController we can only have one callback of
> each type. HTML allows multiple callbacks.
> Maybe they should all be "events" (a simpler non-stream source of events). I'm
> sure that's what they would be in C#, but they have good syntactic sugar for
it.
> 
> As for fixing the current problem - I'd add getters here and setters on
> StreamSubscription, and change the methods to getters in 2.0 (or whenever such
a
> breaking change can be done).
> 
> As a property name, it should probably have been onListenCallback or
> onListenHandler. Nobody will thank us for making them write extra letters,
> though.
> 

I'm fine with these being setters as long as there are getters as well.

Powered by Google App Engine
This is Rietveld 408576698