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

Support custom components #79

Open
YerkoPalma opened this issue May 22, 2017 · 1 comment
Open

Support custom components #79

YerkoPalma opened this issue May 22, 2017 · 1 comment

Comments

@YerkoPalma
Copy link
Member

First of all, I want to know if this makes sense to you, I have more doubts than answer but here are my thoughs. Basically, allow to write this code (taking the list example from readme):

// ...
function render (selected) {
    return bel`<div className="app">
      <h1>Selected: ${selected}</h1>
      ${list(bears, onselected)}
    </div>`
  }
// ...

like this

// ...
function render (selected) {
    return bel`<div className="app">
      <h1>Selected: ${selected}</h1>
      <CustomList source=${JSON.stringify(bears)} onselected=${onselected}>
      </CustomList>
    </div>`
  }
// ...

Implementation shouldn't be so hard, unless I'm missing something, it would need a registration method for components, and when evaluating tags, if the tag is a registered component, use the registered function for that component. The benefit I see here is for frameworks/libraries depending on bel in supporting components, like in choo . and also the similarity with other component based libraries like React and Vue. Now my doubt is if those benefit are enough for changing bel. Also, this change wouldn't be a breaking change, just a minor release.

Any thoughts about it? Am I talking nonsense? 🙊

@aaaristo
Copy link

aaaristo commented Jun 3, 2017

Had the same "issue", and solved it like this: https://github.com/aaaristo/rbel

Would be cool to know if there is any better way.

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

2 participants