jorgebucaran / hyperapp

1kB-ish JavaScript framework for building hypertext applications
MIT License
19.06k stars 781 forks source link

Export internal dispatch function. #735

Closed dmitry-kurmanov closed 6 years ago

dmitry-kurmanov commented 6 years ago

from the https://github.com/hyperapp/hyperapp/issues/672 👍

Interoperability Absolutely. The app function will now return a dispatch function (instead of "wired actions") so you can execute actions or effects at will.

Will dispatch be returned from the app? I think that it can be very helpfull for my needs.

jorgebucaran commented 6 years ago

@dmitrykurmanov The plan is not to, but if a use case arises I will, of course.

What is your use case? Maybe I can offer an alternative using V2's effects/subscriptions API.

dmitry-kurmanov commented 6 years ago

@jorgebucaran I am one of SurveyJS contibutors. And I am creating web controls(widgets). So my usecase the same - do something with App outside the App. For example call actions to change the state or add event handlers to listen action calls.

Because of hyperapp's small codebase it would be ok to include it inside any complex component. And that's why I am asking you so much about interopability :)
I would like to understand whether hyperapp can be the basis for JS contorol libraries.

I've tried the same with vuejs, knockoutjs and preact. Preact is closer to my needs but doesn't include state container out of the box and even Preact larger than hyperapp. If we talk about controls the size and simplicity is more important than same thing in the ednpoint apps. So I love the Hyperapp idea.

For example imagine "hyperbutton" library : export default hyperbutton = app({...}) and then user (programmist) can do the following things:

hyperbutton.click(); // if he want to click progrmmatically instead of end user browser click
hyperbutton.onClick = () => {showPopup();} // event listener

I can do it with hyperapp v1.0 (all except adding event listeners calls after DOM update)

@jorgebucaran At the same time, I do not want to distract you from creating a framework. I don't have any estimations and please feel free to close the issue and I can return back in the future.

jorgebucaran commented 6 years ago

@dmitrykurmanov Thanks! Do you have a more specific use case?

Anyone else? 🙏

dmitry-kurmanov commented 6 years ago

@jorgebucaran

Do you have a more specific use case?

No, This is some kind of common question about framework's possibilities. But without that I think that I can't create library with hyperapp as engine. May be I am wrong.

jorgebucaran commented 6 years ago

@dmitrykurmanov If you share your use case I can help you or explain how you can without dispatch. Now, perhaps you think you already did but I didn't understand it? It happens. I'll give https://github.com/hyperapp/hyperapp/issues/735#issuecomment-406797428 another try/read.

A more concrete way to help would be to explain how you'd what you want to do in HAV1. Can you try doing that? Thanks!

dmitry-kurmanov commented 6 years ago

@jorgebucaran ok, I've posted the example repo here. Please see https://github.com/dmitrykurmanov/hypertree. It uses hyperapp v1.0. Thank you for the fast response!

jorgebucaran commented 6 years ago

@dmitrykurmanov Seems like some sort of tree view component. You have no demo or screenshot, so I had to imagine something like this.

screen shot 2018-07-22 at 9 46 10

Is that what you had in mind?

Creating a tree view component has really nothing to do with the current topic of conversation. It's totally possible to create tree-view-like components using Hyperapp's state-first/single-state approach. I haven't built one myself, but searching for "elm tree-view" revealed several examples.

jorgebucaran commented 6 years ago

@dmitrykurmanov I think we have a communication problem. I understand that English is not your first language. It isn't mine either, but when asking questions, we ought to make a great effort if we want great answers.

If you want to move forward with this, please help me understand what is it that you are asking. I am afraid I don't understand what https://github.com/hyperapp/hyperapp/issues/732 is about either or whether it is related to #735.

jorgebucaran commented 6 years ago

@dmitrykurmanov I put together a short summary for you! 😄

@dmitrykurmanov Can I also suggest some selected reading? Check out Scaling The Elm Architecture and What are lifecycle events for?

dmitry-kurmanov commented 6 years ago

@jorgebucaran I am sorry for my Engish. In fact it is Runglish (Russian + English) 😄 I will work on it.

Thank you for the summary and for the reading suggestions. I'll check it.

dmitry-kurmanov commented 6 years ago

Oh I've missed your other comments:

Seems like some sort of tree view component... Is that what you had in mind?

Yes but it is just example. It can be any other component.

If you want to move forward with this, please help me understand what is it that you are asking. I am afraid I don't understand what #732 is about either or whether it is related to #735.

Yes it is related to #732. But I am afraid that I can't explain it for now with my language skill. I will add a demo and a little bit docs to my repo, may be it will help.