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

Feature/pure components #2795

Merged
merged 4 commits into from
Dec 21, 2019
Merged

Feature/pure components #2795

merged 4 commits into from
Dec 21, 2019

Conversation

GianlucaGuarini
Copy link
Member

Add pure components rendering

@GianlucaGuarini
Copy link
Member Author

GianlucaGuarini commented Dec 21, 2019

This PR enables the use of riot.pure to handle the riot components rendering however you like. For example if you want to use lit-html as rendering engine you can use it directly in your components:

<lit-element>
<script>
  import { pure } from 'riot'
  import { html, render } from 'lit-html'

  export default pure(({ attributes, slots, props }) => ({
    mount(el, context) { 
      this.el = el
      this.render(context)
    },
    // context here is either the parent component or undefined
    render(context) {
      render(html`<p>{ context ? context.message : 'no message defined' }</p>`, this.el)
    },
    unmount() {
      this.el.parentNode.removeChild(this.el)
    }
  }))
</script>
</lit-element>

@GianlucaGuarini GianlucaGuarini merged commit 6277642 into dev Dec 21, 2019
@GianlucaGuarini GianlucaGuarini deleted the feature/pure-components branch December 21, 2019 15:10
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.

None yet

1 participant