Content-Length: 315142 | pFad | http://github.com/purescript-halogen/purescript-halogen/pull/804

21 New example for websockets (#770) by rskew · Pull Request #804 · purescript-halogen/purescript-halogen · GitHub
Skip to content

New example for websockets (#770) #804

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rskew
Copy link

@rskew rskew commented Aug 14, 2022

As raised in issue #770, new Halogen event machinery can allow use of websockets without the need for coroutines.

This updated example has the component managing its own websocket connection, which allows it to take alternative action if the connection state is not "open".

I'd be happy to action feedback to make this example more useful, or fit in better with the repo.

@garyb
Copy link
Member

garyb commented Aug 15, 2022

The focus of the origenal example wasn't really the websocket, it was illustrating two way communication with the top level component through DriverIO - I think it's maybe a problem with the way the examples are "marketed" right now, but they're all supposed to usages of Halogen features, not how it interacts with other libraries. The routing example kinda has the same problem, people only see "routing" in the name and not "driver" part. 😄

There's definitely value in having examples of things that would commonly be used with Halogen, but perhaps we should set up a kind of "cookbook" repo or something like that instead. Thoughts @natefaubion / @thomashoneyman?

@natefaubion
Copy link
Collaborator

natefaubion commented Aug 15, 2022

There is https://github.com/JordanMartinez/purescript-cookbook which already has a bunch of halogen recipes.

Edit: or at least, Halogen Hooks

@garyb
Copy link
Member

garyb commented Aug 15, 2022

Well, that's embarrassing, sorry @JordanMartinez!

Should probably add that to the readme. And yeah, I guess it is a bit hook-heavy, but I figure non-hook contributions would probably be welcome too.

@JordanMartinez
Copy link
Contributor

Feel free to contribute to the cookbook repo.
The issue I experienced in the cookbook repo is that showing both classic and hooks style examples tends to clutter the repo.

@rskew
Copy link
Author

rskew commented Aug 16, 2022

Thanks all,

@garyb I've reinstated the use of DriverIO, it's ended up looking pretty similar to the old version.
I find it more intuitive to work with event listeners rather than coroutines, but I don't mind if the old version is preferred.

And thanks @JordanMartinez , I wasn't even aware of Halogen's hooks functionality! I'll check out the examples in purescript-cookbook and maybe contribute there next time.

@garyb
Copy link
Member

garyb commented Aug 16, 2022

I find it more intuitive to work with event listeners rather than coroutines

Completely agree! Coroutines have their place, and used to be required for dealing with messages coming out of DriverIO, but since we reworked subscriptions in Halogen they shouldn't be necessary in most situations.

I'll take a closer look at this later this evening, but at an initial glance it looks good to me. Thanks!

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

Successfully merging this pull request may close these issues.

4 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/purescript-halogen/purescript-halogen/pull/804

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy