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

Create a small, focused FRP stream library #51

Open
jaidetree opened this issue Apr 12, 2020 · 1 comment
Open

Create a small, focused FRP stream library #51

jaidetree opened this issue Apr 12, 2020 · 1 comment
Labels
develop develop branch todo

Comments

@jaidetree
Copy link
Collaborator

jaidetree commented Apr 12, 2020

There's quite a lot of async code in this library. Currently, it's managed with callbacks, but we all know how much fun those are, especially if you come from node.

I really like working with FRP streams such as RxJS, Highland JS, and Bacon so creating a more focused version for this project (and other people's fennel projects) could help us model complex interactions very trivially.

Intended interface

(local stream {:require stream})

(-> (stream.fromCallback fs.timer.doAfter 3)
    (stream.map (fn [_] "hello"))
    (stream.subscribe print))

With a few more constructors and some higher-order operations, we can do some really cool things to tie two or more otherwise unrelated async operations together.

For example:

(-> (stream.fromWatcher app-focus-watcher)
    (stream.combine (stream.fromCallback ts.eventtap.new [events.keyup]))
    (stream.map hs.inspect)
    (stream.subscribe print))

This would give us a stream of events where a user switches app focus and presses a key which is typically very complicated to model with callbacks and typically requires a lot of mutable state.

This will likely help improving more complex features like vim mode as well as even opening up greater possibilities for animation.

Animation with RxJS

I've started the research phase, learning about the Observer pattern which seems to be at the core of most stream implementations I've worked with.

If anyone can recommend an existing library or even tutorials on how to implement a library like that, it would be greatly appreciated.

@jaidetree jaidetree added develop develop branch todo labels Apr 12, 2020
@agzam
Copy link
Owner

agzam commented Apr 22, 2020

whoa.. that would be awesome! Observables make so much sense since we're dealing with lots of things we can simplify with that pattern. Maybe also take a look at https://github.com/bjornbytes/RxLua

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
develop develop branch todo
Projects
None yet
Development

No branches or pull requests

2 participants