也许出站端口不支持任务? [英] Maybe Task not supported on outbound ports?

查看:85
本文介绍了也许出站端口不支持任务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎收到此错误

Trying to send an unsupported type through outbound port `projectRequests`

    port projectRequests : Signal (Maybe (Task String ()))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The specific unsupported type is:

   Task.Task String ()

The types of values that can flow through outbound ports include: Ints, Floats, Bools, Strings, Maybes, Lists, Arrays, Tuples, Json.Values, and concrete records.

但这似乎很好

port orgRequests : Signal (Task String ())

我对这里发生的事情感到困惑.

I am confused as to what is going on here.

推荐答案

有两种方法可以使用

  • 将数据发送到JavaScript,您可以在其中编写自己的处理程序来处理它.这仅限于可以轻松转换的数据子集 JS值.
  • Task发送到要计划执行的运行时.
    1. Send data to out to JavaScript, where you write your own handler to deal with it. This is limited to a subset of data that can be easily transformed to JS values.
    2. Send Tasks to the runtime to be scheduled for execution.

    在这种情况下,数据(Maybe)包裹在Task周围,因此编译器假定(错误*)要使用端口1.

    In this case you have data (Maybe) wrapped around your Task, so the compiler assumes (wrongly*) that you want to the use the port for purpose #1.

    如果要执行SignalJust中包裹的Task,而对Signal上的Nothing不执行任何操作,则可以过滤出Nothing并展开Just Signal.Extra.filter Signal.filterMap identity:

    If you want to execute the Tasks wrapped in Justs on the Signal and do nothing on a Nothing on the Signal, you can filter out the Nothing and unwrap the Just with Signal.Extra.filter or Signal.filterMap identity:

    port projectRequests : Signal (Maybe (Task String ()))
    port projectRequests = Signal.filterMap identity -- and then whatever you had here before
    

    **您能否将此错误消息报告给错误消息目录?该消息可能会更好,因为它可以根据Task猜测您的意图是您要发送的数据类型.

    *Can you please report this error message to the error message catalog? This message could be better since it can guess your intentions from the Task being in the type of the data you're trying to send out.

    这篇关于也许出站端口不支持任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆