Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFE: MX support to simplify Dart Stream processing #1

Open
kennytilton opened this issue May 13, 2023 · 0 comments
Open

RFE: MX support to simplify Dart Stream processing #1

kennytilton opened this issue May 13, 2023 · 0 comments
Assignees

Comments

@kennytilton
Copy link
Owner

Background

Currently, a widget can fairly elegantly handle a stream with a pair of cells:

{:msg-source (cF+ [:watch (fn [_ me ^#/(async/StreamController String) new-source old-source _]
                            (.listen (.-stream ^#/(async/StreamController String) new-source)
                              (fn [^String msg]
                                (mset! me :msg-rcvd msg))))]
               (mget (fm* :msg-sender) :msg-stream))
 :msg-rcvd   (cI "<none>" :ephemeral? true)}

Nice, but Streams are common in Flutter.

The RFE: support streams with one cell

Because Streams are fairly common in Dart/Flutter, we would like to handle a stream with a single cell, perhaps:

{:msg-rcvd (cF+ [:sink (fn [_ me ^#/(async/StreamController String) new-source old-source _]
                         (.listen (.-stream ^#/(async/StreamController String) new-source)
                           (fn [^String msg]
                             (mset! me :msg-rcvd msg))))]
             (mget (fm* :msg-sender) :msg-stream))}

Notes:

  • if the formula has a dependency, meaning it could end up seeing a new stream, we should seamlessly change over to that;
  • the :async? option starts at nil pending the result. Do we need to make that a specifiable value?
  • should this cell default to :ephemeral true?

Also, a stream can have a lot of callbacks:

  onPause: () => print('Paused'),
  onResume: () => print('Resumed'),
  onCancel: () => print('Cancelled'),
  onListen: () => print('Listens'),

Do we have to address those? One solution might be to handle elaborate stream processing with the current 2-cell approach, and reserve the 1-cell approach for simple cases. The 2-cell approach is not all that bad.

Comments? Questions?

@kennytilton kennytilton self-assigned this May 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant