-
Notifications
You must be signed in to change notification settings - Fork 377
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Add conditional export to support --wasm build (#3363)
* fix: Add conditional export to support --wasm build * Add stubs for extension --------- Co-authored-by: Simon Binder <oss@simonbinder.eu>
- Loading branch information
Showing
2 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import 'package:stream_channel/stream_channel.dart'; | ||
|
||
/// Extension to transform a raw `MessagePort` from web workers into a Dart | ||
/// [StreamChannel]. | ||
extension PortToChannel on dynamic { | ||
/// Converts this port to a two-way communication channel, exposed as a | ||
/// [StreamChannel]. | ||
/// | ||
/// This can be used to implement a remote database connection over service | ||
/// workers. | ||
/// | ||
/// The [explicitClose] parameter can be used to control whether a close | ||
/// message should be sent through the channel when it is closed. This will | ||
/// cause it to be closed on the other end as well. Note that this is not a | ||
/// reliable way of determining channel closures though, as there is no event | ||
/// for channels being closed due to a tab or worker being closed. | ||
/// Both "ends" of a JS channel calling [channel] on their part must use the | ||
/// value for [explicitClose]. | ||
@Deprecated( | ||
'Please use MessagePorts from package:web instead of those from dart:html. ' | ||
'This extension will be removed from drift once `dart:html` is removed ' | ||
'from the SDK.', | ||
) | ||
StreamChannel<Object?> channel({bool explicitClose = false}) { | ||
throw 'If this import was resolved, dart:html is not available.'; | ||
} | ||
} |
This file contains 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