No refs? What about 3rd party libraries? #75
-
|
Complete noob here.. just stumbled across Rimmel while looking up observables. It sounds like there's no alternative to refs? Fine. But is there any way in general to get a reference to an actual dom element? The documentation claims that 'forwarded refs' aren't necessary because we don't need to control the state of elements since Rimmel can. Well, that would be fine if that were the problem refs solved, but even React claims that element refs are meant as an escape hatch mostly for embedding third-party embeds - and never suggests using them for managing state manually. So, in Rimmel, I'm assuming I'm just missing it, but how would I embed, e.g., a list of Ace editors on a page? TIA |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Hi @CodeSmith32, this is an excellent question. The "no access to elements" is a principle for day-to-day development to keep streams declarative and help separating concerns. When creating low-level integrations or fine tuning things are obviously a bit different. The idea, just like with side effects, is not to eliminate them, which would be impossible, but rather to maintain a clean separation. There are a few ways to get access to the actual DOM element.
So, back to your question, a custom element could be a nice and convenient way to embed the Ace editor in any code. If you don't want to use custom elements, but you're still aiming for reusability, you can create a regular JS component: If you just want to make any element "editable", a mixin could be a good fit: If it's for a quick and dirty PoC, with onmount it would work like: Looking forward to see what do you come up with, if you're happy to share, or happy to help if you're stuck. In a near future we might even come up with some generic sink/adapter for any vanilla JS modules like Ace, or maybe even for jQuery plugins. If you want to get involved, give a shout! |
Beta Was this translation helpful? Give feedback.
Hi @CodeSmith32, this is an excellent question.
The "no access to elements" is a principle for day-to-day development to keep streams declarative and help separating concerns.
When creating low-level integrations or fine tuning things are obviously a bit different. The idea, just like with side effects, is not to eliminate them, which would be impossible, but rather to maintain a clean separation.
There are a few ways to get access to the actual DOM element.