Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Dart JS Interop 0.6.0和JS承诺-解决_Dart_Dart Html_Dart Js Interop - Fatal编程技术网

Dart JS Interop 0.6.0和JS承诺-解决

Dart JS Interop 0.6.0和JS承诺-解决,dart,dart-html,dart-js-interop,Dart,Dart Html,Dart Js Interop,Interop或dart2JS似乎没有明确拦截JS承诺 ServiceWorkerContainer swContain = window.navigator.serworker; swContain.register(workerScriptURI,scope).then((ServiceWorkerRegistration rego){ /// Here confirm scope and the state, handle and unregister if required. )};

Interop或dart2JS似乎没有明确拦截JS承诺

ServiceWorkerContainer swContain = window.navigator.serworker;

swContain.register(workerScriptURI,scope).then((ServiceWorkerRegistration rego){
/// Here confirm scope and the state, handle and unregister if required.
)};
然而,如果没有包装好承诺和完整性,似乎无法实现这一目标。当我离开时,我就不能以一种可靠的方式去工作

长柱:

我正在使用的变通方法

因此,这与0.6.0的效果一样:

@JS("Promise")
class Promise {

external void then(Function onFulfilled, Function onRejected);
external Static Promise resolve (dynamic value);
}

@JS("ServiceWorkerContainer")
class ServiceWorkerContainer {

external Promise register(String scriptURL, Map options)
}

main(){

    ServiceWorkContainer swCTX = navigator.serviceWorker;

    successHandler(dynamic value) {
       // Call Promise resolve(value) if the not settled.  Ultimately

       ServiceWorkerRegistration swRego = value;

       // Now call anything you want on the Rego, just wrap what you need.

    failureHandler(dynamic value) {
       // Deal with it here


    /// This the main show here.
    swCTX.register('script-name.dart.js', scope).then(allowInterop(successHandler), allowInterop(failureHandler))

}
我尝试将上述内容与现有的“dart:html”库混合,以避免包装太多内容。但隐藏进口商品和诸如此类的东西让事情变得一团糟


一旦async/await得到承诺,所有的舞蹈都将变得毫无意义。我省略了一些包装,基本上如果你需要对象或其中的值,你就需要包装。

你似乎没有明确提出任何具体的问题,任何人都可以在这里帮助回答……这是一个悬而未决的问题。你可以回答你自己的问题。我觉得这比给你的问题添加答案要好。目前,由于仍然缺少直接支持,因此只能采取变通办法。