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

Add Refs to HTML widgets #17

Merged
merged 5 commits into from Aug 25, 2022
Merged

Add Refs to HTML widgets #17

merged 5 commits into from Aug 25, 2022

Conversation

hamsbrar
Copy link
Member

@hamsbrar hamsbrar commented Jul 30, 2022

Description

This pull request is about adding Refs support in Rad's HTML widgets.

Providing 'a declarative way' for everything sounds great but hard to accomplish. There are number of cases where users simply want the framework to get out of their way. We already provide few escape hatches like RawMarkUp widget but sometimes users want to access DOM elements that are associated with HTML widgets. Rather than forcing users to go underneath the framework ( document.getElementById ), we should provide a much easy and predictable way i.e Refs.

This feature is similar to React's Refs but with few differences:

  • Only callback Refs, no legacy string/createRef APIs.
  • Only on HTML widgets(we want refs to be a feature of widget not framework)

Progress

Update: With the support for RenderEvents(v1.2.0), we can add Refs without adjusting anything in the core.

  • Implement Refs in HTML base widget.
  • Add ref property to all HTML widgets(only HTML widgets, for now).

Benchmark results

Updated Benchmark results

@hamsbrar
Copy link
Member Author

hamsbrar commented Aug 1, 2022

There are couple of things that I think can be improved.

  1. RenderElement can provide more granular control over its lifecycle.

  2. With more control over lifecycle, we can possibly short-circuit dispose(s).

These two optimizations cannot be made once we merge this PR, at least not without introducing breaking changes so we're going to experiment few things in #19 before merging this.

@hamsbrar hamsbrar force-pushed the dev-refs branch 3 times, most recently from 8b083d4 to 564e711 Compare August 6, 2022 09:43
@hamsbrar hamsbrar marked this pull request as ready for review August 6, 2022 09:58
@hamsbrar hamsbrar merged commit df87d68 into main Aug 25, 2022
@hamsbrar hamsbrar deleted the dev-refs branch August 25, 2022 06:40
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