File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 1+ import 'package:stream_channel/stream_channel.dart' ;
2+
3+ /// Extension to transform a raw `MessagePort` from web workers into a Dart
4+ /// [StreamChannel] .
5+ extension PortToChannel on dynamic {
6+ /// Converts this port to a two-way communication channel, exposed as a
7+ /// [StreamChannel] .
8+ ///
9+ /// This can be used to implement a remote database connection over service
10+ /// workers.
11+ ///
12+ /// The [explicitClose] parameter can be used to control whether a close
13+ /// message should be sent through the channel when it is closed. This will
14+ /// cause it to be closed on the other end as well. Note that this is not a
15+ /// reliable way of determining channel closures though, as there is no event
16+ /// for channels being closed due to a tab or worker being closed.
17+ /// Both "ends" of a JS channel calling [channel] on their part must use the
18+ /// value for [explicitClose] .
19+ @Deprecated (
20+ 'Please use MessagePorts from package:web instead of those from dart:html. '
21+ 'This extension will be removed from drift once `dart:html` is removed '
22+ 'from the SDK.' ,
23+ )
24+ StreamChannel <Object ?> channel ({bool explicitClose = false }) {
25+ throw 'If this import was resolved, dart:html is not available.' ;
26+ }
27+ }
Original file line number Diff line number Diff line change @@ -12,5 +12,6 @@ library drift.web;
1212export 'src/web/sql_js.dart' ;
1313export 'src/web/storage.dart' hide CustomSchemaVersionSave;
1414export 'src/web/web_db.dart' ;
15- export 'src/web/channel_legacy.dart' ;
15+ export 'src/web/channel_legacy_dummy.dart'
16+ if (dart.library.html) 'src/web/channel_legacy.dart' ;
1617export 'src/web/channel_new.dart' ;
You can’t perform that action at this time.
0 commit comments