-
Notifications
You must be signed in to change notification settings - Fork 20
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
Using concur-replica for components #34
Comments
Yeah, I've thought about this as well, here are some experiments regarding this in the Replica repo. The basic idea is to piggyback on the evend dispatch -> server -> VDOM patch -> client loop, so that components send custom events to the server (e.g. a However, I suspect it would be now possible to do that reusing the new JS FFI functionality, without having to patch Replica. EDIT:
That's a cool idea! Shouldn't be too hard in principle, but needs some thought. |
I'd love it if you gave it a shot. I took a look at the JS code but it seemed just a bit too involved to do without knowing the details. |
Note to self, investigate custom components. |
Hi, I have tried custom components with this code and found something. Only connectedCallback (when custom element show without previous same custom element) and disconnectedCallback (when custom element is not included in new doms.) works.
|
Ah, I think you misspelled |
@pkamenarsky , Oops. Thanks for spotting that. Now attributedChangedCallback is called before every connectedCallback, but not before disconnectedCallback, as expected. |
I suspect this is because you haven't registered
|
Actually, after I registered the second element, it becomes: (before clicking any button) (first click) (second click) (third click) it seems it will always call attributeChangedCallback before it calls connectCallback, even in the first show when there is no any button clicking. I don't know if it is right. But it makes sense to me. I can live with that. |
And if I don't register the second element, I get: (click 1) (click 2) (click 3) I will always get one more attributeChangedCallback before it connects. Other than that, I get the order you specified. |
Yeah, that seems about right - see https://github.com/pkamenarsky/replica/blob/master/js/client.ts#L370. When inserting a new node we first attach its children, then set the attributes and as a last step add it to the DOM. It's somewhat strange that custom components will call the |
What would be the easiest way to do this?
Say I'm writing an app in Haskell but a part of the app calls for a code editor. I'm not going to reimplement that in concur-replica so I'd like to just include that JS component where from the concur perspective it's just a widget that finishes once the user submits what's written. What I'd also like is a way to then have smaller concur components inside the JS code editor. For example, autocomplete dropdowns or things like that. So a Haskell wrapper for JS components and a JS wrapper for Haskell components.
Do you think this is feasible?
The text was updated successfully, but these errors were encountered: