From 1cf0faa8ac6cc9be06bf9db323e90e20c672f344 Mon Sep 17 00:00:00 2001 From: Bee Date: Wed, 22 Jan 2020 13:30:02 -0800 Subject: [PATCH] Make tweaks to parent class def --- lib/src/node/worker_threads.dart | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/src/node/worker_threads.dart b/lib/src/node/worker_threads.dart index 6ddea3129..0b39833bd 100644 --- a/lib/src/node/worker_threads.dart +++ b/lib/src/node/worker_threads.dart @@ -1,16 +1,19 @@ // Copyright 2017 Google Inc. Use of this source code is governed by an // MIT-style license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT. -@JS() +@JS("worker_threads") library worker_threads; import 'package:js/js.dart'; import 'package:js/js_util.dart'; -@JS() -external Object _requireWorkerThreads(String path); +typedef _WorkerThreads = void Function() Function( + String Function(String), String Function(String)); + +@JS('require') +external Object _requireWorkerThreads(String name); -final workers = _requireWorkerThreads("worker_threads"); +final _worker = _requireWorkerThreads("worker_threads"); @JS() external Object get workerData; @@ -46,7 +49,9 @@ class PortOptions { @JS() external ParentPort get parentPort; -@JS() -class ParentPort { - external static void postMessage(Object message, PortOptions options); +@JS("parentPort") +@anonymous +abstract class ParentPort { + external factory ParentPort({Function postMessage}); + external void postMessage(Object message, PortOptions options); }