Skip to content
This repository has been archived by the owner on Feb 25, 2025. It is now read-only.

Commit

Permalink
Rename DimensionsProvider.onHotRestart to .close, and slightly improv…
Browse files Browse the repository at this point in the history
…e docs.
  • Loading branch information
ditman committed Dec 21, 2022
1 parent 0a817a6 commit b293d36
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class CustomElementDimensionsProvider extends DimensionsProvider {
}

@override
void onHotRestart() {
void close() {
_hostElementResizeObserver?.disconnect();
// ignore:unawaited_futures
_onResizeStreamController.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ abstract class DimensionsProvider {
/// Returns a Stream with the changes to [ui.Size] (when cheap to get).
Stream<ui.Size?> get onResize;

/// Clears all the resources grabbed by the DimensionsProvider instance.
void onHotRestart();
/// Clears any resources grabbed by the DimensionsProvider instance.
///
/// All internal event handlers will be disconnected, and the [onResize] Stream
/// will be closed.
void close();
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class FullPageDimensionsProvider extends DimensionsProvider {
}

@override
void onHotRestart() {
void close() {
_domResizeSubscription.cancel();
// ignore:unawaited_futures
_onResizeStreamController.close();
Expand Down
2 changes: 1 addition & 1 deletion lib/web_ui/lib/src/engine/window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class EngineFlutterWindow extends ui.SingletonFlutterWindow {
registerHotRestartListener(() {
_browserHistory?.dispose();
renderer.clearFragmentProgramCache();
_dimensionsProvider.onHotRestart();
_dimensionsProvider.close();
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void doTests() {
});

tearDown(() {
provider.onHotRestart(); // cleanup
provider.close(); // cleanup
sizeSource.remove();
});

Expand Down Expand Up @@ -67,7 +67,7 @@ void doTests() {
});

tearDown(() {
provider.onHotRestart(); // cleanup
provider.close(); // cleanup
sizeSource.remove();
});

Expand Down Expand Up @@ -105,7 +105,7 @@ void doTests() {
});

tearDown(() {
provider.onHotRestart(); // cleanup
provider.close(); // cleanup
sizeSource.remove();
});

Expand Down Expand Up @@ -155,7 +155,7 @@ void doTests() {
});

// Should close the stream
provider.onHotRestart();
provider.close();

sizeSource
..style.width = '100px'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void doTests() {
});

// Should close the stream
provider.onHotRestart();
provider.close();

resizeEventTarget.dispatchEvent(createDomEvent('Event', 'resize'));

Expand Down

0 comments on commit b293d36

Please sign in to comment.